gsharp gsharp - 1 year ago 377
C# Question

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

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?

Answer Source

If you're targeting .NET 4.6.1 or lower or .NET Core, you need to install the NuGet package System.ValueTuple:

Install-Package "System.ValueTuple" -IncludePrerelease

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download