Null-Coalescing Operator
noun
say it: “NUL koh-uh-LES-ing OP-er-ay-ter” /nʌl ˌkoʊəˈlɛsɪŋ ˈɒpəreɪtər/
The ?? operator, which uses the value on its right when the value on its left is null.
What does Null-Coalescing Operator do in C#?
Null-Coalescing Operator — The ?? operator, which uses a fallback when its left value is null.
class Profile
{
string DisplayName(string? nickname)
{
return nickname ?? "Guest";
}
}
In a sentence
- “With the null-coalescing operator, region ?? "(none)" prints (none) for missing regions.”
Level: Journeyman · More C# terms at this level
Updated