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;

Official C# 14 documentation

More basics commands

All basics commands · C# 14 cheatsheet

Was this page helpful?