如何在Visual Studio 2017项目中启用C#7的所有功能?

编程入门 行业动态 更新时间:2024-10-22 08:22:25
本文介绍了如何在Visual Studio 2017项目中启用C#7的所有功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

Visual Studio 2017发布后,我想尝试使用新的C#7功能创建简单的控制台项目.我希望我只是下载新的Visual Studio 2017,然后创建新的控制台项目并可以使用新的C#7功能.但是我不能.

After Visual Studio 2017 was released I wanted to try to create simple console project with new C# 7 features. I expected that I simply download new Visual Studio 2017, then create new console project and can use new C# 7 features. But I can't.

如果安装 NuGet,我可以使用某些功能,例如元组包System.ValueTuple .

但是对于其他功能,我不知道需要做什么.例如此NuGet问题.

But for other features, I don't know what I need to do. For example this NuGet issue.

我现在需要做所有这些肮脏的安装吗?或者我可以以更简单的方式启用c#7功能?

Do I need to do all this dirty install now? Or I can enable c# 7 features in a more simple way?

推荐答案

对于您在问题第二部分中链接到的任意任务式类型,您需要包含 System.Threading.Tasks.Extensions 包.

For arbitrary task-like types you linked to in the 2nd part of your question you need to include the System.Threading.Tasks.Extensions package.

之所以需要这些NuGet软件包,是因为新的语言功能依赖于添加到.NET框架中的新类型.直到4.6.2之后发行的下一个次要版本不破坏 SemVer 1 .因此,除非您要使用该框架的下一个版本来构建项目,否则将需要使用NuGet软件包才能使这些功能正常工作.

The reason you need these NuGet packages is because the new language features rely on new types added to the .NET framework. The new types that the C# language features depend on will not be "built in to the framework" until the next minor version released after 4.6.2 to not break SemVer1. So unless you are building a project using that next version of the framework you will need to use the NuGet packages to get the features to work.

此与让扩展方法在.NET 2.0项目中工作没什么不同.您可以使用扩展方法,但需要使用NuGet包(或自己添加代码)来获取依赖的类型,以将其添加到您的项目中.

This is no different than getting extension methods to work in a .NET 2.0 project. You can use extension methods but you need to use a NuGet package (or add the code yourself) to get the types it relies on to be added to your project.

1:所以4.7或5.0,无论他们决定如何称呼它,如果有4.6.3,它将不在该版本中,因为那不是次要发行版本的颠簸,而是补丁版本的颠簸并且您不能在不违反语义版本控制的情况下对补丁版本进行API更改.

更多推荐

如何在Visual Studio 2017项目中启用C#7的所有功能?

本文发布于:2023-11-03 15:41:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555472.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:功能   项目   如何在   Studio   Visual

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!