Visual Studio 2017 (15.x) 支持 C# 7,但 Visual Studio 2015 (14.x) 呢?
我如何使用它来使用 C# 7?
最佳答案
您可以通过安装 Nuget 包 Microsoft.Net.Compilers 将 Visual Studio 随附的编译器替换为支持 C# 7 的版本:
Referencing this package will cause the project to be built using the specific version of the C# and Visual Basic compilers contained in the package, as opposed to any system installed version.
没有迹象表明我可以在包页面上看到它是否在 Visual Studio 2015 中得到正式支持。到目前为止我的不彻底测试表明它可以工作但并非无痛 - C# 7 代码编译,但有下划线带有表示语法错误的红色波浪线: 请注意,您还需要安装 Nuget 包 System.ValueTuple使用新的 C# 7 值元组功能。
关于c# - 如何在 Visual Studio 2015 中使用 C# 7?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39461407/