简体   繁体   English

将 C# Windows 窗体项目更新到最新的 C# 版本

[英]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?我有一个 C# Windows Forms 项目,但我需要将其更新到 C# 语言的最新版本,但我不了解更新的文档,有人有如何执行此操作的示例吗?

I'm using version 4.6 of Net Framework, I've tried it with 4.8 too我正在使用 4.6 版的 Net Framework,我也用 4.8 尝试过

You can set the LangVersion property in the .csproj file to specify the C# version you'd like to use.您可以在 .csproj 文件中设置 LangVersion 属性以指定您要使用的 C# 版本。 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.请注意,只有 C# 语言的某些版本与特定的 .NET 版本MSBuild 版本兼容。 The highest version of C# compatible with .NET Framework is 7.3.与 .NET Framework 兼容的 C# 的最高版本是 7.3。

You can find more information, including C# / .NET version compatibility, here:您可以在此处找到更多信息,包括 C#/.NET 版本兼容性:

C# language versioning C# 语言版本控制

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

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