首页 > 代码库 > 单例类

单例类

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; }
    }
}

 

单例类