单利模式的应用
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; } } }
?
?
?