泛型单例

/// <summary>
/// 创建单例对象
/// </summary>
/// <typeparam name="T"></typeparam>
public sealed class Singleton<T> where T : new()
{
/// <summary>
/// 单例对象
/// </summary>
public static readonly T Instance;
/// <summary>
/// 静态构造
/// </summary>
static Singleton()
{
Instance = new T();
}
}

posted @ 2016-05-16 10:00  zslm___  阅读(152)  评论(0编辑  收藏  举报