Possible Duplicate:
What is the “??” operator for?
I have recently come across the ??
operator in C#. What does this operator do and when would someone use it?
Example:
string name = nameVariable ?? string.Empty;
The ?? operator basically means "or if it is null, blah". It is equivalent to:
string name = (nameVariable == null) ? string.Empty : nameVariable;
Which, if you're not familiar with the syntax, is basically:
string name;
if (nameVariable == null)
name = string.Empty;
else
name = nameVariable;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With