Roslyn retail branch cannot use C # 7 tuples - Error CS0518 Predefined type 'System.ValueTuple`2

I am trying to test some C # 7 features as described in this blog.

https://joshvarty.wordpress.com/2016/02/10/lrn-quick-tip-how-to-test-out-c-7-features-with-roslyn/

I have followed these steps many times, and I have projects to create and open a new instance of Visual Studio. As soon as I open the instance, I create a new console project from the file menu. When I try to use Tuples, I get the following error.

Error CS0518 Predefined type 'System.ValueTuple`2' is not defined or imported 

I'm not sure if I am doing something wrong? I feel that there is one setting that is missing.

+5
source share
3 answers

I solved this problem manually, including the System.ValueTuple class from roslyn github repository

+4
source

Install the NuGet package "System.ValueTuple": https://www.nuget.org/packages/System.ValueTuple/

+8
source

In the Visual Studio menu;
Tools => NuGet Package Manager => Package Manager Console

A type:
Install-Package System.ValueTuple

eg.:

 (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); 
+2
source

All Articles