07 Lazy Initialization of Fields

A not so obvious use for the ?? operator to initialize fields lazily, instead of:

public static MyType MySingleton
{
  get 
  {
    if (SingletonInstance == null)
      SingletonInstance = new MyType();
    return SingletonInstance;
  }
}
 
private static MyType SingletonInstance;

the ?? operator can be used to make the getter wonderfully concise:

public static MyType MySingleton
{
  get { SingletonInstance ?? (SingletonInstance = new MyType()); } 
}