I blog about development using .net, C#, SQL, Windows RT, and other Microsoft technologies.
Disclaimer: All posts are provided "AS IS" with no warranties, confering no rights, and expressing only my personal opinion, not Microsoft's.
The ?? operator is used to return the left operand if it's not null, otherwise, it returns the right operand. It's equivalent to (left != null ? left : right).
string a = null; object b = a ?? new object(); object c = b ?? "b is null!"; int? x = null; int y;
// These statements should be equivalent:
y = x ?? default(int); y = x.GetValueOrDefault(); y = x.HasValue ? x.Value : default(int);y = x != null ? x.Value : default(int);
For more info, please read: ?? Operator (C# Reference) and default Keyword in Generic Code (C# Programming Guide)