C# Feature - Nullable reference types
Overview
Section titled βOverviewβNullable reference types use annotations and flow analysis so the compiler can warn when null may violate a reference type contract.
Introduced In
Section titled βIntroduced InβC# 8.0 (2019)
string name = FindName();Console.WriteLine(name.Length);string? name = FindName();Console.WriteLine(name?.Length ?? 0);Gotchas & Best Practices
Section titled βGotchas & Best Practicesβ- Enable nullable context project-wide instead of file by file when possible.
- Treat warnings as design feedback, not just compiler noise.