Checking for Null Values

Learn how to handle null values in C# by checking for null in nullable reference type and nullable value type variables and use operators.

Checking whether a nullable reference type or nullable value type variable currently contains null is important because if we do not, a NullReferenceException can be thrown, which results in an error.

Handling null values

We should check for a null value before using a nullable variable, as shown in the following code:

Get hands-on with 1400+ tech skills courses.