private static void Singleton() { SingleTonSample.InstanceCreation(); SingleTonSample.InstanceCreation(); Console.ReadLine(); //throw new NotImplementedException(); }
public static SingleTonSample InstanceCreation() { //singleTonObject = new Lazy<SingleTonSample>(() => new SingleTonSample() // ); //return singleTonObject.Value; if (singleTonObject == null) { lock (lockingObject) { if (singleTonObject == null) { singleTonObject = new SingleTonSample(); // Console.WriteLine("Singleton instance is created."); } } } return(singleTonObject); }