C# 14 · Basics
Handle null safely
Mark possibly-null reference types with ?. The compiler warns when you dereference them.
string? nickname = null;
int length = nickname?.Length ?? 0;
C# 14 · Basics
Mark possibly-null reference types with ?. The compiler warns when you dereference them.
string? nickname = null;
int length = nickname?.Length ?? 0;
Was this page helpful?