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)
Before
Section titled “Before”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.