Ejemplo n.º 1
0
        public static void SingletonCommand()
        {
            Singleton myvar = Singleton.GetInstance();

            Console.WriteLine("This is the Singleton pattern. It restricts the instantiation of a class to one object.");
            Console.Write("Please input a message for the only object to write back to you: ");
            string input = Console.ReadLine();

            myvar.DoSomething(input);
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Singleton s1 = Singleton.GetSingleton();
            Singleton s2 = Singleton.GetSingleton();

            s1.DoSomething();
            if (s1 == s2)
            {
                Console.WriteLine("s1 and s2 point to the same object");
            }
            Console.ReadLine();
        }