C# – The ?? operator or coalesce operator
May 2, 2011, 6:00 am
Here is a little code that returns either x or y. It returns y if x is null, otherwise it returns x.
return (x == null) ? y : x;
The coalesce operator is basically short hand for this. The ?? operator simplifies and shortens the above expression.
return x ?? y;