ValueTuple Error in Visual Studio 15 Preview 3
The introduction of the new tuple feature in Visual Studio 15 Preview 3 sparked excitement among developers. However, some users encountered the "Predefined type 'System.ValueTuple´2´ is not defined or imported" error when compiling code.
This error indicates that the "System.ValueTuple" type is not recognized by the compiler. While the blog post suggests that this feature is enabled by default, it is not the case for certain frameworks and versions.
Solution
For .NET 4.6.2 or lower, .NET Core 1.x, and .NET Standard 1.x, the "System.ValueTuple" NuGet package must be installed:
Install-Package "System.ValueTuple"
Alternatively, in Visual Studio 2017, a package reference can be added:
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
.NET Frameworks and Versions
It is important to note that different frameworks and versions include this type by default:
By using the NuGet package or package reference, users can access the "System.ValueTuple" type in lower versions of these frameworks, allowing them to utilize the tuple feature.
The above is the detailed content of Why Am I Getting a 'Predefined type 'System.ValueTuple' is not defined or imported' Error in Visual Studio?. For more information, please follow other related articles on the PHP Chinese website!