Nullable type or double question mark in C#

By | December 16, 2017

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.


int? x = null;
// Set y to the value of x if x is NOT null; otherwise, set y to -1.
int y = x ?? -1;
Like it? Share it