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的所有功能?
发布评论