运行 C# v.<latest> 在带有 .NET 4.0 的 Windows 7 上

Running C# v.<latest> on a Win 7 w/ .NET 4.0

我们正在编写一个必须在 Windows 7 上 运行 的应用程序...我们无法在这些客户端计算机上安装新版本的 .NET 框架。作为开发人员,我想使用所有新奇的 C# 6.0 语言功能,如果我理解正确的话,语言和框架已经解耦了。

我只需要澄清一下:如果我在我的应用程序中以 C# 6.0 为目标,代码在 .NET 4.0 作为最高框架版本的 Win7 客户端上是否仍然 运行 正确?

是的,您可以在面向旧版本的 .NET 时使用 C# 6 编译器。这通常的工作方式是您拥有更新版本的 Visual Studio 并将其定位于特定的 .NET 版本。对于 C# 6,this means VS2015. You will be able to use any new C# features, as long as they don't rely on .NET libraries. In particular cases, such as if you want to use async stuff, there are backward compatibility libraries 可用。

直接使用csc.exe(C#编译器),绕过Visual Studio.