标签:single turn 构造函数 私有 let on() get ati private
记录学习过程
单例模式:单例模式就是保证一个类,只有一个实例;
class Singleton { private static Singleton _instance = null; private static readonly object SynObject = new object(); // 定义私有构造函数,使外界不能创建该类实例 private Singleton() { } public static Singleton Instance { get { if (_instance == null) { lock (SynObject) { if (_instance == null) { _instance = new Singleton(); } } } return _instance; } } }
标签:single turn 构造函数 私有 let on() get ati private
原文地址:http://www.cnblogs.com/yizhituoxie/p/7833946.html