问题
How can I turn on C# preview features in Visual Studio?
The feature 'nullable reference types' is currently in Preview and "unsupported". To use Preview features, use the 'preview' language version.
The project Properties does not offer "unsupported preview of next C# version (preview)" as an option:
回答1:
Synopsis
In order to turn on the preview features, you need all these:
- Visual Studio preview (recommended)
- .NET preview (required)
- Change the Project Application settings
- Change the Project Build settings
Step by Step
- Download Visual Studio 2019 Preview
- Download .NET SDK Preview for Visual Studio
- Check your installation from a cmd-line:
> dotnet --list-sdks
2.1.202 [C:\Program Files\dotnet\sdk]
…
2.2.101 [C:\Program Files\dotnet\sdk]
3.0.100-preview6-012264 [C:\Program Files\dotnet\sdk]
- Right-click on your Project → Properties → Application
Pick the Target Framework (note the link to Install other frameworks… as well) - In Project → Properties → Build
Select Advanced… (Advanced Build Settings)
Select the desired C# version:
回答2:
I my case I needed to check this checkbox (and restart Visual Studio!)
来源:https://stackoverflow.com/questions/56639685/use-preview-features-preview-language-in-visual-studio