예제 #1
0
        static void Main(string[] args)
        {
            SingletonObject ObjSingleton = SingletonObject.getInstance();

            ObjSingleton.ShowMessage();

            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            SingletonObject singletonObject = SingletonObject.Instance;

            singletonObject.DoSomething();
            SingletonObject.Instance.DoSomething();

            var s = SingletonObject.Instance;

            s.DoSomething();
        }
예제 #3
0
        /// <summary>
        /// Singleton DP Demonstration
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            /*
             *
             *  //You would normally do this but method is private
             *  SingleObject singleObject = new SingleObject();
             */

            // Returns the instance var
            SingletonObject so = SingletonObject.getInstance();

            so.showMessage();
        }
예제 #4
0
        static void Main(string[] args)
        {
            var myObj = SingletonObject.GetInstance();

            myObj.Name = "My Singleton Object";

            var myObj2 = SingletonObject.GetInstance();

            var myObj3 = SingletonObject.GetInstance();

            Console.WriteLine(myObj.Name);
            Console.WriteLine(myObj2.Name);
            Console.WriteLine(myObj3.Name);
        }