未定义或导入预定义类型“ System.ValueTuple´2” [英] Predefined type 'System.ValueTuple´2´ is not defined or imported

查看:232
本文介绍了未定义或导入预定义类型“ System.ValueTuple´2”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了Visual Studio 15 Preview 3,并尝试使用新的元组功能

I've installed Visual Studio 15 Preview 3 and tried to use the new tuple feature

static void Main(string[] args)
{
    var x = DoSomething();
    Console.WriteLine(x.x);
}

static (int x, int y) DoSomething()
{
    return (1, 2);
}

编译时出现错误:


未定义或导入'System.ValueTuple´2'预定义类型

Predefined type 'System.ValueTuple´2´ is not defined or imported

根据博客帖子,默认情况下此功能应处于启用状态。

According to the blog post, this features should be "on" by default.

我做错了什么?

推荐答案

.NET 4.6 .2或更低版本,.NET Core 1.x和.NET Standard 1.x,您需要安装NuGet软件包 System.ValueTuple

For .NET 4.6.2 or lower, .NET Core 1.x, and .NET Standard 1.x you need to install the NuGet package System.ValueTuple:

Install-Package "System.ValueTuple"

或在VS 2017中使用包引用:

Or using a package reference in VS 2017:

<PackageReference Include="System.ValueTuple" Version="4.4.0" />

.NET Framework 4.7,.NET Core 2.0和.NET Standard 2.0包括这些类型。

.NET Framework 4.7, .NET Core 2.0, and .NET Standard 2.0 include these types.

这篇关于未定义或导入预定义类型“ System.ValueTuple´2”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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