Singleton Pattern

6/22/2012 12:45:03 PM

Singleton pattern with lock


private static readonly object Lock = new object();
private static MyClass _instance;
public static MyClass GetInstance
{
   get
   {
        lock (Lock)
        {
            return _instance ?? (_instance = new MyClass());
        }
   }
}