null-coalescing assignment
The C# ??= operator, which assigns the right-hand value only if the left-hand variable is currently null.
In more detail
_currency ??= defaultCurrency sets a default once and never overwrites a real value. Its sibling ?? returns the right-hand value when the left is null.
Related terms
- null-keyword — A special value meaning a reference points at nothing.
Taught in
- Records, Pattern Matching, and Modern C# — Modern .NET Core, C# & Enterprise Microservices