Null Coalescing Operator C#
The ?? operator is also known as the null-coalescing operator. It returns the left side operand if the operand is not null else it returns the right side operand. This article explains what is nullable types, the null coalescing operator, and unique ways to use the null-coalescing operator in C#.
Contents
- C# Nullables
- What Is Null Coalescing Operator In C#?
- Null Coalescing Operators In Practical Scenarios
- Further Reading
- References
C# Nullables
A reference type can have an actual value of null, meaning it has no value. A value type can’t have a value of null.
For example, how would you express that some boolean value is true, false, or unknown? Regular Boolean can be only true or false.