Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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); } 

When I compile I get the error:

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

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

What did I do wrong?

like image 433
gsharp Avatar asked Jul 14 '16 19:07

gsharp


1 Answers

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" 

Or using a package reference in VS 2017:

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

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

like image 61
Eli Arbel Avatar answered Oct 06 '22 19:10

Eli Arbel