标签:sys system ret color class singleton als equals var
饿汉, 懒汉模式就不说了,下面是IODH模式
static void Main(string[] args) { Singleton s1, s2; s1 = Singleton.getInstance(); s2 = Singleton.getInstance(); var obj = System.Object.Equals(s1, s2); }
1 public class Singleton 2 { 3 private Singleton() { } 4 private static class HolderClass 5 { 6 public static Singleton instance = new Singleton(); 7 } 8 public static Singleton getInstance() 9 { 10 return HolderClass.instance; 11 } 12 }
标签:sys system ret color class singleton als equals var
原文地址:http://www.cnblogs.com/hank-chen/p/6245552.html