'Nullable reference types C#

I am trying to use code from classes in a console program in classes for a forms program so our project can have a working GUI and that console program used nullable reference types. how can i bypass this so i get the same functionality?

    static private Radio? _radio;

enter image description here solution explorer



Solution 1:[1]

You have to update .csproj file to support C# 8.0 version and enable nullable option,

  <PropertyGroup>
    <LangVersion>8.0</LangVersion>
    <Nullable>enable</Nullable>
  </PropertyGroup>

How to edit .csproj file?

  • Right click on GUI Version 1 project -> Click on Edit Project file -> Update file with above two tags -> Reload project.

enter image description here

Alternate way:

  • Right click on GUI Version 1 project -> unload project -> Edit project File -> Update file -> Reload project.

enter image description here

Note: Image and GIF content is just for demo purpose, .csproj content will be different for you

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1