The C# Coalesce (??) Operator

The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand.
[sourcecode language=”C#”]

if (myObject == null)
{
myObject = new MyClass();
}
return myObject;

[/sourcecode]

The above code can be represented using the one-liner below.
[sourcecode language=”C#”]

return myObject ?? new MyClass();

[/sourcecode]