I had never heard about C#’s ?? operator until stumbling upon it in MSDN today.
?? is similar to ? : , in that one value is returned from two options depending on the statement evaluating to true. ?? ’s logic operation is to check for not null.For example (from MSDN):
int? x = null; int y = x ?? -1;
y will equal -1 in this case, because x is null. Note also the use of nullable types (int?)
If we change y:
int? x = 10; int y = x ?? -1;
In this case y equals 10, because x is not null.
Handy.
