Thursday 6 December 2018

C# 8.0 and Project-wide nullable reference types

C# 8.0 is available for use in Visual Studio 2019 Preview.  Mads Torgersen explains some of the key features in this video.

He explains how to enforce usage in a single file using

#nullable enable

What Mads doesn't explain is how to fully accept the new Nullable Reference Types for your entire project.

The secret is to add this to your .csproj file:

<NullableReferenceTypes>true</NullableReferenceTypes>

It goes here:


Now your whole project enforces nullable reference types!

Credit to this Reddit comment.

No comments:

Post a Comment