Adding to the previous answers, C # 7 adds value type tuples, unlike System.Tuple , which is a reference type, and also offers improved semantics.
You can still leave them unnamed and use the .Item* syntax:
(string, string, int) getPerson() { return ("John", "Doe", 42); } var person = getPerson(); person.Item1;
But what is really powerful in this new feature is the ability to have named tuples. Therefore, we could rewrite the above as follows:
(string FirstName, string LastName, int Age) getPerson() { return ("John", "Doe", 42); } var person = getPerson(); person.FirstName;
Destructuring is also supported:
(string firstName, string lastName, int age) = getPerson()
dimlucas Jun 06 '17 at 11:44 on 2017-06-06 11:44
source share