Tuesday, 8 October 2013

C#.Net Null Coalescing Operator and its Uses

The C# Null Coalescing Operator (??) could be a binary operator that simplifies checking for null values. It is used with each nullable varieties and reference varieties. during this article, we are going to see a way to use the Null coalescing operators in sensible eventualities.

he C# Null Coalescing Operator (??) could be a binary operator that simplifies checking for null values. It is used with each nullable varieties and reference varieties. it's diagrammatic as x ?? y which suggests if x is non-null, valuate to x; otherwise, y. within the syntax x ?? y

x is that the 1st quantity that could be a variable of a nullable sort.
y is that the second quantity that incorporates a non-nullable price of an equivalent sort.
While death penalty code, if x evaluates to null, y is came because the price. conjointly keep in mind that the null coalescing operator (??) is right-associative which suggests it's evaluated from right to left. therefore if you have got associate degree expression of the shape x ?? y ?? z, this expression is evaluated as x?? (y?? z).

Note: different right-associative operators area unit assignment operators, lambda and conditional operators.

Now with an summary of the C# Null Coalescing operator, allow us to see a way to use the Null coalescing operators in sensible eventualities.

0 comments:

Post a Comment