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