Advertisement
Beginner C#, Nullable Reference Types

What are nullable reference types (NRTs)?

Short answer

An opt-in compiler feature where reference types are non-null by default and nullability is expressed with ?, giving warnings when you might dereference null.

Save C# mock interview
Advertisement
AModel answer
An opt-in compiler feature where reference types are non-null by default and nullability is expressed with ?, giving warnings when you might dereference null.
string name = "x";   // must not be null
string? middle = null; // may be null
Real-world example
Catching potential NullReferenceExceptions at compile time instead of in production.