C# how to change Language version in VS

Viewed 2213

I can not change the language version in VS 2019, the field is disabled, why? how to enable it?

enter image description here

1 Answers

You can use the LangVersion tag in your Project file, C# language versioning

The latest C# compiler determines a default language version based on your project's target framework or frameworks. Visual Studio doesn't provide a UI to change the value, but you can change it by editing the csproj file.

E.g

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

Or any found here C# language version reference

However read the notes, only some version are available in certain frameworks. And some are only partially supported

Related