Example #1
0
        public static ClasseSingleton Instance()
        {
            if (_instance == null)
            {
                _instance = new ClasseSingleton();
            }

            return(_instance);
        }
Example #2
0
        static void ImplementacaoBasica()
        {
            var instance = ClasseSingleton.Instance();

            Console.WriteLine($"Primeira chamada: {instance.Id}");

            var instance2 = ClasseSingleton.Instance();

            Console.WriteLine($"Segunda chamada: {instance2.Id}");
        }