All pastes #474253 Raw Edit

Stuff

public text v1 · immutable
·published 2007-05-06 18:30 UTC
rendered paste body
    public class SingletonClass
    {
        // Instance of the class
        private static SingletonClass _instance;

        // Private constructor, whole point of a singleton
        private SingletonClass()
        {
        }

        // Accessor for singleton instance
        public static SingletonClass Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new SingletonClass();
                }

                return _instance;
            }
        }