示例#1
0
 // GetInstance method to return the instance of this class...
 public static StandSingleton GetInstanceMethod()
 {
     if (standSingleton == null)
     {
         Console.WriteLine("Standarded Implementation Create Instance by Method.....");
         standSingleton = new StandSingleton();
     }
     return(standSingleton);
 }
示例#2
0
        static void SingleTonImp()
        {
            // Standared Implementation method
            StandSingleton.GetInstanceMethod();
            // Standared Implementation Propery
            StandSingleton objStand = StandSingleton.GetInstancePropperty;

            //Multithreading Singleton Implementation Property
            MultiThreadSingleton objMulti = MultiThreadSingleton.GetInstancePropery;

            //Multithreading Singleton Implementation Method
            MultiThreadSingleton.GetInstanceMethod();

            //Double Check Multithreading Singleton Implementation Method
            DblChkMultiThreadSingleton.GetInstanceMethod();
            //Double Check Multithreading Singleton Implementation Method
            DblChkMultiThreadSingleton objDblChkMulti = DblChkMultiThreadSingleton.GetInstanceProperty;

            //Early Instance Singleton Implementation Property
            EarlySingleton objEarlySing = EarlySingleton.GetInstanceProperty;

            //Early Instance Singleton Implementation Method
            EarlySingleton.GetInstanceMethod();
        }