读书人

单利形式的应用

发布时间: 2012-12-25 16:18:28 作者: rapoo

单利模式的应用

using System; using System.Collections.Generic; using System.Text; namespace WindowsApplication1 {     public class Test     {         private static Test test;//已本类为属性的一个静态属性。         //构造私有 其他类无法用new实例化。         private Test()         {         }          //以本类为返回值的静态方法。调用该方法是创建本类的单例对象         public static Test jia()         {             if (test == null)             {                 test = new Test();             }             return test;         }     } } 

?

?

?

读书人网 >编程

热点推荐