简体   繁体   English

C# 如何在VS中更改语言版本

[英]C# how to change Language version in VS

I can not change the language version in VS 2019, the field is disabled, why?我在VS 2019中无法更改语言版本,该字段被禁用,为什么? how to enable it?如何启用它?

在此处输入图像描述

You can use the LangVersion tag in your Project file, C# language versioning您可以在项目文件中使用LangVersion标记, C# 语言版本控制

The latest C# compiler determines a default language version based on your project's target framework or frameworks.最新的 C# 编译器会根据您项目的目标框架或多个框架确定默认语言版本。 Visual Studio doesn't provide a UI to change the value, but you can change it by editing the csproj file. Visual Studio 不提供用于更改值的 UI,但您可以通过编辑 csproj 文件来更改它。

Eg例如

<PropertyGroup>
  <TargetFramework>netstandard2.1</TargetFramework>
  <LangVersion>Latest</LangVersion>
   ...
</PropertyGroup>

Or any found here C# language version reference或任何在这里找到的C# 语言版本参考

However read the notes, only some version are available in certain frameworks.但是请阅读说明,某些框架中只有一些版本可用。 And some are only partially supported有些只是部分支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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