C# 12 Required Members Help Too
The required keyword forces callers to initialize properties. Combined with primary constructor syntax in C# 12 it removes a whole class of uninitialized-field bugs without needing nullable gymnastics.
Null reference exceptions, nullable reference types in C# 8+, and whether Tony Hoare's billion-dollar mistake was actually that bad.
The required keyword forces callers to initialize properties. Combined with primary constructor syntax in C# 12 it removes a whole class of uninitialized-field bugs without needing nullable gymnastics.
Hot take: in business code, just throw ArgumentNullException at the top of every public method. Fail fast, fail loudly. The nullable annotations are great but retrofitting them onto a 500k-line codebase is a months-long project nobody will ever approve.
Enable <Nullable>enable</Nullable> in your .csproj and treat every warning as an error. After a few weeks of pain it becomes second nature and your code gets dramatically safer. The ?. and ?? operators do most of the heavy lifting. string? name = GetName(); var display = name ?? "Anonymous";
In functional languages you use Option<T> / Maybe<T> instead of null. There are C# libraries like LanguageExt that bring this pattern over. You get compiler-enforced exhaustive handling instead of hoping nobody forgot a null check.