2011年7月12日
摘要: 在项目里,看到了一段单例的实现代码,想到以前看TerryLee的单例模式时,提到的那个延迟初始化的实现方式,原来就是这样用的。public class Singleton { class Nest { static Nest() { } internal static readonly Singleton instance = new Singleton(); } public static Singleton Instance { get { return Nest.instance; } }}另外,项目里用得更多的是双重检测的单例public class Singleton2 { priv 阅读全文
posted @ 2011-07-12 16:43 冷酒少 阅读(220) 评论(0) 推荐(0) 编辑