public static void GetSingleton() { var s = SingleTon.GetInstance(); var s2 = SingleTon.GetInstance(); var s3 = SingleTon.GetInstance(); Console.WriteLine(s.GetHashCode()); Console.WriteLine(s2.GetHashCode()); Console.WriteLine(s3.GetHashCode()); }
public static SingleTon GetInstance() { if (instance == null) { instance = new SingleTon(); return(instance); } else { return(instance); } }