Home >Backend Development >C++ >Why am I getting the 'Predefined type 'System.ValueTuple' is not defined or imported' error in .NET?

Why am I getting the 'Predefined type 'System.ValueTuple' is not defined or imported' error in .NET?

Linda Hamilton
Linda HamiltonOriginal
2024-12-31 10:21:10683browse

Why am I getting the

Error: "Predefined type 'System.ValueTuple' is not defined or imported"

When attempting to use the new tuple feature in .NET Core, developers may encounter the error "Predefined type 'System.ValueTuple' is not defined or imported." This error indicates that the necessary tuple type has not been defined or imported into the project.

Despite the blog post suggesting that the feature should be enabled by default, it may not be in all cases. To resolve this issue, developers need to install the System.ValueTuple NuGet package.

For .NET 4.6.2 or lower, .NET Core 1.x, and .NET Standard 1.x, use the following PowerShell command:

Install-Package "System.ValueTuple"

In Visual Studio 2017, use a package reference:

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

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

The above is the detailed content of Why am I getting the 'Predefined type 'System.ValueTuple' is not defined or imported' error in .NET?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn