← Back to /cs/

Why does everyone hate nulls?_

Null reference exceptions, nullable reference types in C# 8+, and whether Tony Hoare's billion-dollar mistake was actually that bad.

By: alice_dev Mar 24, 2026 5 posts
#1 Mar 28

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.

By: alice_dev Mar 28, 2026 18:39
#2 Mar 27

Just Use Guard Clauses

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.

By: dave_runtime Mar 27, 2026 18:39
#3 Mar 26

Option<T> is the Real Answer

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.

By: carol_null Mar 26, 2026 18:39
#4 Mar 25

Nullable Reference Types Help a Lot

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";

By: bob_codes Mar 25, 2026 18:39
[1] [2] Page 1 of 2 (5 posts)
5 posts in this thread [+] Reply