働きたくない、社会が怖い|

时而有风

园龄:1年4个月粉丝:0关注:0

C# 单例使用

public class Singleton
{
    #region 单例方法

    private static Singleton instance;

    private Singleton()
    {
    }

    public static Singleton Instance()
    {
        if (instance == null)
        {
            lock (typeof(Singleton))
            {
                if (instance == null)
                {
                    instance = new Singleton();
                }
            }
        }

        return instance;
    }

    #endregion
}

 

本文作者:shieryoufeng

本文链接:https://www.cnblogs.com/shieryoufeng/p/17788689.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   时而有风  阅读(22)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起