Coder Perfect

‘System’ is a predefined type. There is no ValueTuple’2′ defined or imported.


I tried with the new tuple functionality in Visual Studio 15 Preview 3 by installing it.

static void Main(string[] args)
    var x = DoSomething();

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

When I try to compile, I receive the following error:

This feature should be “on” by default, according to the blog article.

What went wrong with me?

Asked by gsharp

Solution #1

The NuGet package System is required for.NET 4.6.2 or lower,.NET Core 1.x, and.NET Standard 1.x. ValueTuple:

Install-Package "System.ValueTuple"

In Visual Studio 2017, you may also use a package reference:

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

These types are included in.NET Framework 4.7,.NET Core 2.0, and.NET Standard 2.0.

Answered by Eli Arbel

Solution #2

It’s included in.NET Framework 4.7.

You’ll need to reference ValueTuple if you’re not targeting the aforementioned framework or higher (or.NET Core 2.0 /.NET Standard 2.0). By introducing the System, you may accomplish this. ValueTuple NuGet Package

Answered by Nikita

Solution #3

Newer frameworks include the ValueTuple types:

You must use the ValueTuple package until you target one of the latest framework versions. for more information.

Answered by Julien Couvreur

Solution #4

Use the built-in Terminal in Visual Studio Code to run:

dotnet add package "System.ValueTuple"

Don’t forget to run dotnet restore when you’re finished.

Answered by Sebastian Krogull

Solution #5

Ensure you have the.NET 4.6.2 Developer Pack for Visual Studio installed before adding System. NuGet’s ValueTuple package.

Answered by Poulad

Post is based on