Monday, March 7, 2011

Null Coalescing Operator

Null Coalescing Operator represented by double question marks ?? can be very usefull in comparing "null" values in handy manner.

For example
myfunc is a function which my return null values. In these kind of situatuion, you can use the coalescing operator which can return an alternate provided value if the returned value is null.

int ExpectedValueIfNull = 10;
int Value = myfunc() ??   ExpectedValueIfNull

No comments:

Post a Comment