摘要:
public sealed class Singleton{ Singleton() { } public static Singleton Instance { get { return Nested.instance; } } class Nested { static Nested() { } internal static readonly Singleton instance = new Singleton(); }}这是C#单例模式中“延迟初始化”的代码,延迟初始化就是在用到的时候才加载对象实例化,这里也可以声明为静态对象,比如:public sealed class Single 阅读全文
posted @ 2011-05-07 16:27
九月的海
阅读(219)
评论(0)
推荐(0)

浙公网安备 33010602011771号