一位大牛写的单例

public sealed class Singleton
{
    Singleton()
    {
    }

    public static Singleton Instance
    {
        get
        {
            return Nested.instance;
        }
    }

    class Nested
    {
        // Explicit static constructor to tell C# compiler
        // not to mark type as beforefieldinit
        static Nested()
        {
        }

        internal static readonly Singleton instance = new Singleton();
    }
}

  大家感受下

 

posted @ 2014-07-11 23:40  Aways.Online  阅读(366)  评论(2编辑  收藏  举报