Null coalescing operator (??)

From msdn http://msdn.microsoft.com/en-us/library/ms173224.aspx

The ?? operator is called the null-coalescing operator and is used to define a default value for a nullable value types as well as reference types. It returns the left-hand operand if it is not null; otherwise it returns the right operand.

Example:

// y = x, unless x is null, in which case y = -1.
int y = x ?? -1;

Leave a comment