This isn't something that most web developers know about because tuples aren't commonly used in web development. It's not because they aren't usefu...
For further actions, you may consider blocking this person and/or reporting abuse
Well, there is a difference between the System.Tuple types and the new ValueTuple that has been added since C# 7. In fact
ValueTuple
is a value type (not a reference type) which brings additional performance benefit and should be prefered overSystem.Tuple
.Since you're mentioning that a
Tuple
is a reference type and then mention the recently addedValueTuple
, you could further complete the information with the fact that theValueTuple
is a struct (value type) 👍.Important take into account that we need to use framework 4.6.2 in order to implement tuples and it has a feature for 7.1.
7.0:
int count = 5;
string label = "Colors used in the map";
var pair = (count: count, label: label);
7.1 (new feature default names):
int count = 5;
string label = "Colors used in the map";
var pair = (count, label); // element names are "count" and "label"
I love how C# is embracing good parts from other languages.
I use the 7.1 syntax in Javascript quite much and been tripping me much in C#.
Mathematically, a tuple is a "sorted list".