The introduction of System.ValueTuple makes using Tuples in .NET a lot more user friendly and fixes the mistake of making System.Tuple<> a reference type.
Creating a tuple becomes this easy:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var idandvalue = (id:1, value:"test"); |
Still there are some rough edges, for example what do you think will happen if I try to execute the following code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(id: 1, value: "test") == (id: 1, value: "test"); |
Turns out that the ValueTuple has no built in support for equality checks:
In F# this works without a problem: