I'm trying to test some C#7 features as outlined in this blog.
https://joshvarty.wordpress.com/2016/02/10/lrn-quick-tip-how-to-test-out-c-7-features-with-roslyn/
I've followed the steps many times and I've got the projects to build and open a new instance of Visual Studio. Once I open the instance, I'm then creating a new console project from the file menu. When I attempt to use the Tuples I get the following error.
Error CS0518 Predefined type 'System.ValueTuple`2' is not defined or imported
I'm not sure if I'm doing something wrong? I'm feeling like there's one tweak that's missing.
Install the "System.ValueTuple" NuGet package: https://www.nuget.org/packages/System.ValueTuple/
I solved this issue by manually including the System.ValueTuple
class from the roslyn github repository
In Visual Studio Menu;
Tools => NuGet Package Manager => Package Manager Console
Type:
Install-Package System.ValueTuple
e.g.:
(string Name, int Number) LookupName() // tuple return type
{
return ("Siya", 16); // tuple literal
}
// In the caller:
var res = LookupName();
var resText = $"Name: {res.Name}, Number: {res.Number}";
Debug.WriteLine(resText);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With