C# – Suppress nullable warnings (CS8602)

Sometimes the compiler shows unhelpful nullable warnings. Here’s an example of it showing warning CS8602, when it’s obvious to any human reading the code that you’re doing a null-check already (in ThrowIfNull()): Besides disabling the Nullable feature, there are two ways to suppress nullable warnings on a case-by-case basis: I’ll show both options below. Option … Read more

C# – Nullable Reference Types feature basics

The main purpose of the Nullable Reference Types (NRT) feature is to help prevent NullReferenceExceptions by showing you compiler warnings. You can make a reference type nullable (ex: Movie? movie) or non-nullable (ex: Movie movie). This allows you to indicate how you plan on using these references. The compiler uses this info while analyzing actual … Read more