by Edward
18 September 2009 05:50
The "??" operator returns the left-hand operand if it is NOT NULL, otherwise it will return the right operand.
For example:
int? i = null;
// y = i, unless i is null, in which case y = -1.
int y = i ?? -1;
The ?? operator also works with reference types:
//message = param, unless param is null
//in which case message = "No message"
string message = param ?? "No message";