(string, string, string) LookupName(long id) // tuple return type { ... // retrieve first, middle and last from data storage return (first, middle, last); // tuple literal }
which could then be used like this:
var names = LookupName(id); WriteLine($"found {names.Item1} {names.Item3}.");
You can also provide names to your elements (so they are not "Item1", "Item2" etc). You can do it by adding a name to the signature or the return methods:
(string first, string middle, string last) LookupName(long id) // tuple elements have names
or
return (first: first, middle: middle, last: last); // named tuple elements in a literal
They can also be deconstructed, which is a pretty nice new feature:
(string first, string middle, string last) = LookupName(id1); // deconstructing declaration