设计模式——单例模式

 1     internal class SingletonOne
 2     {
 3         private static SingletonOne _singleton;
 4         private SingletonOne()
 5         {
 6         }
 7 
 8         public static SingletonOne Instance
 9         {
10             get
11             {
12                 if (_singleton == null)
13                 {
14                     Interlocked.CompareExchange(ref _singleton, new SingletonOne(), null);
15                 }
16 
17                 return _singleton;
18             }
19         }
20     }
原文地址:https://www.cnblogs.com/jaysen/p/5701979.html