Null-Coalescing Operator

The ?? operator, which uses a fallback when its left value 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";
    }
}

Level: Journeyman · More C# terms at this level

Updated