单例类

using System;

public class Singleton<T> where T : class, new()
{
    private static readonly T s_Instance;

    static Singleton()
    {
        s_Instance = Activator.CreateInstance<T>();
    }

    public static T Instance
    {
        get { return s_Instance; }
    }
}

 

posted @ 2016-12-02 21:08  土汉  阅读(152)  评论(0编辑  收藏  举报