Eng. Samer T
Eng. Samer T

Reputation: 6526

C# how to change Language version in VS

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

enter image description here

Upvotes: 8

Views: 8678

Answers (1)

TheGeneral
TheGeneral

Reputation: 81493

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

Upvotes: 3

Related Questions