Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SingletonDemo
- {
- namespace SingletonDemo
- {
- class MainApp
- {
- static void Main(string[] args)
- {
- Singleton s1 = Singleton.Get_Instance();
- Singleton s2 = Singleton.Get_Instance();
- if (s1.Equals(s2))
- Console.WriteLine("The instances are the same!!");
- else
- Console.WriteLine("The instances are different");
- Console.ReadKey();
- }
- }
- sealed class Singleton
- {
- private static Singleton _instance = null;
- private Singleton()
- {
- }
- public static Singleton Get_Instance()
- {
- if (_instance == null)
- _instance = new Singleton();
- return _instance;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement