Null-Coalescing Operator
suggest changeSyntax
var result = possibleNullObject ?? defaultValue;
It is a shorthand for the conditional expression:
possibleNullObject != null ? possibleNullObject : defaultValue
The left-side operand (object being tested) must be a nullable value type or reference type, or a compile error will occur.
The ?? operator works for both reference types and value types.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents