The Core of .NET, Fast Focus

VST07 Fast Focus: Safer Code: Nullability and Null Operators in C#


1:30pm - 1:50pm

Level: Introductory to Intermediate

Jeremy Clark

Developer Educator

New projects in C# have nullable reference types enabled by default. This helps make the intent of our code more clear, and we can catch potential null references before they happen. But things can get confusing, particularly when migrating existing projects. In this session, you will learn about the safeguards that nullability provides as well as the problems you still need to watch out for yourself. In addition, you will learn the various null operators in C# (including null conditional, null coalescing, and null forgiving operators). These can make your code more expressive and safe.

You will learn:

  • How compile-time warnings help you avoid null reference exceptions
  • How to use nullability to make the intent of your code clear
  • How to use the nullability operators: ?, !, ??