C# Feature - Nullable value types
Overview
Section titled βOverviewβNullable value types wrap value types so they can also represent null.
Introduced In
Section titled βIntroduced InβC# 2.0 (2005)
int age = -1;int? age = null;Gotchas & Best Practices
Section titled βGotchas & Best Practicesβ- Prefer
??and pattern matching over manual sentinel values. - Use
HasValueonly when a direct null check is less clear.