In VS2017 RC, when you tried to use new tuple syntax, you received the following error:
CS8179 Predefined type 'System.ValueTuple`X' is not defined or imported
In order to use tuple syntax, you had to manually import ValueTuple nuget package into the project. Not a big deal, as it was pre-release version and I thought it will be changed in RTM so it will be enabled by default. Unfortunately in the final release version it is still the case and you have to download nuget package for every single project to use tuple syntax.
Is there a way to have tuple syntax enabled for every project by default?
A tuple is a lightweight data structure that has a specific number and sequence of values. When you instantiate the tuple, you define the number and the data type of each value (or element). For example, a 2-tuple (or pair) has two elements. The first might be a Boolean value, while the second is a String .
Creating a Tuple A tuple in Python can be created by enclosing all the comma-separated elements inside the parenthesis (). Elements of the tuple are immutable and ordered. It allows duplicate values and can have any number of elements. You can even create an empty tuple.
In F#, tuples provide built-in functions. You can access first element by using fst () and second element by using snd () function.
A tuple is a data structure that has a specific number and sequence of values. The Tuple<T1,T2,T3> class represents a 3-tuple, or triple, which is a tuple that has three components. You can instantiate a Tuple<T1,T2,T3> object by calling either the Tuple<T1,T2,T3> constructor or the static Tuple.
According to https://github.com/dotnet/roslyn/issues/13177, the According to the .NET Framework 4.7 release notes, it has been added. Adding it to 4.6.x would break semver. Hence they provided the types as a Nuget package so that projects based on older framework versions can use it.ITuple
and ValueTuple
types will be added to mscorlib in "the first version after" .NET Framework 4.7.
This is akin to a .NET 2.0 project wanting to use LINQ which the extension methods lived in System.Core, not mscorlib.
One option you could do is create your own project templates in the interim that reference the NuGet package.
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