搜索
您的当前位置:首页C# 最终版单例模式

C# 最终版单例模式

来源:飒榕旅游知识分享网
    public class Sigleton<T> where T : class
    { 
        public static Lazy<Sigleton<T>> _sigleton = new Lazy<Sigleton<T>>(()=>(Sigleton<T>)Activator.CreateInstance(typeof(T)));


        protected Sigleton()
        {

        }

        public static Sigleton<T> Instance
        {
            get
            {
                return _sigleton.Value;
            }
        }

    }

因篇幅问题不能全部显示,请点此查看更多更全内容

Top