RajasekharwhY / Build-your-muscle

Learning concepts and sample practice code - C#, MVC, SQL etc..
2 stars 0 forks source link

?? Operator (null-coalescing operator) #27

Closed RajasekharwhY closed 5 years ago

RajasekharwhY commented 5 years ago

It returns the left hand operand if the operand is not null, if the operand is null it returns the right hand operand.

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