如何在 Visual Studio 2015 中使用 C# 7? [英] How to use C# 7 with Visual Studio 2015?

查看:39
本文介绍了如何在 Visual Studio 2015 中使用 C# 7?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio 2017 (15.x) 支持 C# 7,但 Visual Studio 2015 (14.x) 怎么样?

如何将 C# 7 与它一起使用?

解决方案

您可以通过安装 Nuget 包 请注意,您还需要安装 Nuget 包 System.ValueTuple 使用新的 C# 7 值元组功能.

Visual Studio 2017 (15.x) supports C# 7, but what about Visual Studio 2015 (14.x)?

How can I use C# 7 with it?

解决方案

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.

这篇关于如何在 Visual Studio 2015 中使用 C# 7?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆