Cristiano Rogoy
Cristiano Rogoy

Reputation: 21

Update C# Windows Forms Project to Latest C# Version

I have a C# Windows Forms project but I need to update it to the latest version of the C# language but I don't understand the documentation for updating, does anyone have an example of how to do this?

I'm using version 4.6 of Net Framework, I've tried it with 4.8 too

Upvotes: 2

Views: 654

Answers (1)

Dean2678
Dean2678

Reputation: 21

You can set the LangVersion property in the .csproj file to specify the C# version you'd like to use. You can set it to a specific version, or use "latest" to set it to the latest version compatible with the compiler:

<Project>
 <PropertyGroup>
   <LangVersion>latest</LangVersion>
 </PropertyGroup>
</Project>

Be aware that only certain versions of the C# language are compatible with specific .NET versions and MSBuild Versions. The highest version of C# compatible with .NET Framework is 7.3.

You can find more information, including C# / .NET version compatibility, here:

C# language versioning

Upvotes: 2

Related Questions