Null-Conditional Operator

The ?. operator, which accesses a member only when the value is not null.

What does Null-Conditional Operator do in C#?

Null-Conditional Operator — The ?. operator, which accesses a member only when the value is not null.

class Profile
{
    int? NameLength(string? name)
    {
        return name?.Length;
    }
}

Level: Journeyman · More C# terms at this level

Updated