纸上得来终觉浅,绝知此事要躬行。

 

通用单例模式

public class Singleton<T> where T : class, new()
{
    public static T Value
    {
        get
        {
            return Instance.Value;
        }
    }

    private static class Instance
    {
        public static readonly T Value = new T();
    }
}

 

posted on 2013-11-14 13:06  JRoger  阅读(146)  评论(0编辑  收藏  举报

导航