设计模式:单例模式程序代码范例

/// <summary>
/// 单例模式
/// </summary>
public sealed class Singleton
{
private static Singleton _Singleton = null;
private Singleton()
{
Console.WriteLine("Singleton被shiyh构造");
}

static Singleton()
{
_Singleton = new Singleton();
}

public static Singleton GetInstance()
{
return _Singleton;
}
}

posted @ 2017-04-10 23:22  Mr.石  阅读(269)  评论(0编辑  收藏  举报