How to use c#7 with Visual Studio 2015?

匿名 (未验证) 提交于 2019-12-03 01:49:02

问题:

Visual Studio 15 can be configured to play with some features of C#7, but what about Visual Studio 2015?

How can I use C#7 with it?

回答1:

You can replace the compiler shipped with Visual Studio for a C# 7-enabled version by installing the Nuget package Microsoft.Net.Compilers:

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.

There is no indication that I can see on the package page as to whether this is officially supported in Visual Studio 2015. My not-thorough tests so far indicate that it works but not painlessly - C# 7 code compiles, but is underlined with the red squiggly line which indicates a syntax error:

Note that you will also need to install the Nuget package System.ValueTuple to use the new C# 7 value tuples features.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!