Nullable Reference Types in C# 8

Introduction

With C# 8 you can now use a new feature in the language called Nullable Reference Types.  

The Nullable Reference Types feature in C# 8 is disabled by default even if you specify C# 8 as your language version in Visual Studio

How to enable the feature

You can enable the feature by setting the Nullable property to enable inside your C# project file.

Enabling this feature drastically changes the semantics of your code.

The C# compiler will start working with a different set of rules.

It will consider any variable of a reference type non-nullable and can be dereferenced safely. 

The C# compiler will show a warning all the time you attempt to assign null to a reference type variable.

Learn how you can enable this feature and start fixing nullability issues in your code base. 

Practical Video

Conclusion

The new set of warnings the compiler can generate when you enable the Nullable Reference Types feature, can be a massive help for the developers and will help to spot bugs and write code of better quality. This feature is definitely a game changer for C# developers and I invite you to use it especially on new projects.

Keep Learning...

Top 10 C# Developer News from Microsoft Build 2020
The Microsoft Build 2020 conference this year is completely free. Watch the live event on the official Build 2020 website.[...]
Agile Estimation
Designed by ijeab / Freepik I'd like to share with you some of my notes after taking the course on Agile[...]
Nullable Reference Types in C# 8
Introduction C# 8 introduce switch expression, an elegant and compact new way to write switch statements. It's important to note[...]
Switch Expression in C# 8
Introduction C# 8 introduce switch expression, an elegant and compact new way to write switch statements. It's important to note[...]
How Delegates Work in C#
Most developers new to C# don't fully understand how delegates work and it's a frequently asked question in the Productive[...]
Notes from ProgNET London 2019
In the past three days I attended the ProgNET London 2019 conference.Here my key notes from the various sessions and[...]
Sharing is Caring
>