What does ?? mean in C# ?
You can read the full article but the essence is:
"?? provides a convenient way that I can map the null value of a nullable variable onto a specific value
int actualAge = customerAge ?? -1;
The above statement sets the value of actualAge to the value in customerAge unless the value in customerAge is null, in which case it sets it to –1.
if (customerAge == null)
actualAge = -1;
else actualAge = customerAge;
Enjoy!
No comments:
Post a Comment