C# 单例模式
2021-09-22 01:12
标签:div pre == style nbsp on() let span ons #region Singleton class Singleton { private static Singleton singleton; private static object lockObj = new object(); private Singleton() { } public static Singleton GetInstance() { if (singleton == null) { lock (lockObj) { if (singleton == null) { singleton = new Singleton(); } } } return singleton; } } static void SingletonTest() { Singleton s1 = Singleton.GetInstance(); Singleton s2 = Singleton.GetInstance(); if (s1 == s2) { Console.WriteLine("The same instance"); } } #endregion C# 单例模式标签:div pre == style nbsp on() let span ons 原文地址:http://www.cnblogs.com/zxxxx/p/7400502.html
上一篇:自制CSS面试题答案
下一篇:关于C#的学习心得体会