Nullable types are not new concept for .net and were first introduced in .Net framework 2.0. Microsoft introduced nullability operator i.e. “?” that can be appended to any value type to make it nullable as shown below
int? i;
With C# 8 Microsoft extended nullability behavior to reference types as well. This is done to avoid NullReferenceException by distinguishing between nullable and non-nullable reference types.
Key features of Nullable Reference types are:
1. By default, reference types are treated as non-nullable.
2. You can declare nullable reference types using ? (e.g., string?).
3. Compiler warnings will be issued if you try to assign null to a non-nullable reference type or use a nullable reference type without checking for null.
string? nullableString = null; // No warning
string nonNullableString = null; // Warning: Nullability issue