Null safety in C#

Beginner
Developer
Student
.NET

Learn coding practices to help prevent the occurrence of NullReferenceException.

Learning objectives

In this module, you will:

  • Learn how to configure the nullable context of your C# project or code.
  • Use a nullable enabled context to perform automatic static flow analysis.
  • Understand the different ways in which you can declare nullable types.
  • Learn how and when to use various null-related C# operators:
    • null-forgiving (!) operator
    • null-coalescing (??) operator
    • null-conditional (?.) operator

Prerequisites

  • Experience writing C# at the beginner level
  • Visual Studio Code
  • .NET SDK 6.0 or greater
  • Git command-line client