public void TestCreateSingletonLazy() { SingletonLazy s1 = SingletonLazy.Instance; SingletonLazy s2 = SingletonLazy.Instance; Assert.Same(s1, s2); }
static void Main(string[] args) { SingletonLazy ss = SingletonLazy.Instance; var ss2 = SingletonLazy.Instance; Console.WriteLine(ss); Console.WriteLine(ss2); Console.WriteLine("Hello World!"); }
static void Main(string[] args) { Singleton singleton = Singleton.UniqueInstance; singleton.Log("Initialize"); SingletonLazy singletonLazy = SingletonLazy.UniqueInstance; singletonLazy.Log("Lazy Initialize"); Console.ReadLine(); }
static SingletonCreator() { uniqueInstance = new SingletonLazy(); }