从品牌网站建设到网络营销策划,从策略到执行的一站式服务
The purpose of the Singleton pattern is to ensure that there is only one instance of a class, and that there is a global access point to that object.
Design:
Implementation:
public sealed class Singleton
{
// Private constructor. private Singleton()
{
Console.WriteLine("One instance is created.");
}
// private object instantiated with private constructor. private static readonly Singleton instance = new Singleton();
// Public static property to get the object. public static Singleton UniqueInstance
{
get
{
return instance;
}
}
}
class Program
{
static void Main(string[] args)
{
Singleton s0= Singleton.UniqueInstance;
Singleton s1= Singleton.UniqueInstance;
Singleton s2= Singleton.UniqueInstance;
}
}
成都网站建设公司地址:成都市青羊区太升南路288号锦天国际A座10层 建设咨询028-86922220
成都快上网科技有限公司-四川网站建设设计公司 | 蜀ICP备19037934号 Copyright 2020,ALL Rights Reserved cdkjz.cn | 成都网站建设 | © Copyright 2020版权所有.
专家团队为您提供成都网站建设,成都网站设计,成都品牌网站设计,成都营销型网站制作等服务,成都建网站就找快上网! | 成都网站建设哪家好? | 网站建设地图