February 16

Nullable Reference Types in C# 8



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


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...

Stepping Down as .NET Cambridge Community Leader
Today, I have sent the following email to the .NET Cambridge community members. It was a tough decision, and I[...]
Top 10 C# Developers Videos from .NET Conf 2021
Last week, Microsoft announced .NET 6 and C# 10 at the .NET Conf 2021. It's the most important release in[...]
The best way to stay up to date with C# 10 features
C# is a language that is constantly evolving and it can be hard to stay up to date with all[...]
My Technical Journey from my first program to Lead Software Engineer
I was recently interviewed by Sean Rajnis and I shared with him my programming journey.This is a quick summary:I've learnt[...]
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[...]


You may also like

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Subscribe to our newsletter now!

Get instant access to the Master C# 9 webinar to learn all the new exciting C# 9 features quickly.
Get regular videos and news on C# and .NET and offers on products and services to master C#.

We will collect, use and protect your data in accordance with our Privacy Policy.