C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
How to enable Nullable Reference Types
Introduction
C# 8 introduced a new feature in the language called Nullable Reference Types.
Even if you specify C# 8 as your language version in Visual Studio, the Nullable Reference Types feature in C# 8 is disabled by default.
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 compiler will start working with a different set of rules.
Any variable of a reference type will be considered non-nullable and can be dereferenced safely. The 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.
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.
.NET
C#
4y
34.4k
500
0
0
2
Andrea Angella
Microsoft MVP, master certified C# developer and founder of .NET Cambridge: the official community on .NET in Cambridge (https://www.productivecsharp.com). I love to teach in a simple and practical way how to master the ...
Read more
Microsoft MVP, master certified C# developer and founder of .NET Cambridge: the official community on .NET in Cambridge (https://www.productivecsharp.com). I love to teach in a simple and practical way how to master the C# language and help you to become one of the most productive C# developer in the world. I am a Senior .NET Software Engineer working in Redgate Software. My peers describe me as really enthusiastic, motivated with an infinite passion for software development, a relentless desire to keep learning and an amazing ability to involve others in my pursuit of excellence.
Recommended Videos
Sending WhatsApp Message using C# Code
Sekhar Srinivas
Speech recognition application using C#
Sekhar Srinivas
Practical Introduction To Unit Testing In C# And Visual Studio
Andrea Angella
Message