Skip to content

C# Feature - Nullable value types

Nullable value types wrap value types so they can also represent null.

C# 2.0 (2005)

int age = -1;
int? age = null;
  • Prefer ?? and pattern matching over manual sentinel values.
  • Use HasValue only when a direct null check is less clear.