Singleton provides a global,
Making the class create a single instance of itself.
Making the class create a single instance of itself.
public class SampleSingleton { //SingleTon private static volatile SampleSingleton _instance; private static object syncRoot = new Object(); public static SampleSingleton Instance { get { if (_instance == null) { lock (syncRoot) { if (_instance == null) { _instance = new SampleSingleton(); } } } return _instance; } } public string getDisplay() { return "SingleTon"; } } ///Access singleton SampleSingleton.Instance.getDisplay();