码迷,mamicode.com
首页 > 其他好文 > 详细

单例类

时间:2016-12-03 00:42:42      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:singleton   let   stat   log   private   sys   code   cti   readonly   

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

 

单例类

标签:singleton   let   stat   log   private   sys   code   cti   readonly   

原文地址:http://www.cnblogs.com/zjw007/p/6127362.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!