简体   繁体   中英

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;

在此处输入图像描述 solution explorer

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.

在此处输入图像描述

Alternate way:

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

在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM