Thursday, July 27, 2017

null-coalescing operator ?? double question-mark

The ?? operator is called the null-coalescing operator. It returns the left-hand operand if the operand is not null; otherwise it returns the right hand operand.

(also see: )

not to be confused with:
The conditional operator (?:) returns one of two values depending on the value of a Boolean expression. Following is the syntax for the conditional operator.

There's another more generalized name for this kind of expression, but I cannot recall what it is.  I think I have another page about it somewhere. TERNARY!  ternary operator ....  

ternary because it is composed of "3 parts".

var  thingamajig= Request.QueryString["thingamajig"] ?? Request.Form["thingamajig"];

No comments: