【发布时间】:2016-11-17 21:19:20
【问题描述】:
我已经安装了 Visual Studio 15 Preview 3 并尝试使用新的元组功能
static void Main(string[] args)
{
var x = DoSomething();
Console.WriteLine(x.x);
}
static (int x, int y) DoSomething()
{
return (1, 2);
}
编译时出现错误:
未定义或导入预定义类型“System.ValueTuple´2”
根据the blog post,默认情况下此功能应为“开启”。
我做错了什么?
【问题讨论】:
-
有谁知道即使在 2017 RTM 目标 4.6.2 中是否需要 NuGet 包?看起来你仍然需要它,我预计你不会在最终版本中。
-
你可以尝试使用 System.Tuple
代替 -
对我来说,stackoverflow.com/a/46533630/4383425 是解决方案。
标签: c# visual-studio-2017 c#-7.0