Possible to initialize multiple variables from a tuple?
Valid up to C# 6:
No, this is not possible. There's no such language feature in C#.
If you think the following code:
string firstValue = tupleWithTwoValues.Item1;
string secondValue = tupleWithTwoValues.Item2;
is ugly, then you should reconsider using tuples at the first place.
UPDATE: As of C# 7, tuple deconstruction is now possible. See the documentation for more information.
See Jared's answer as well.
This is now available in C# 7:
public (string first, string last) FullName()
{
return ("Rince", "Wind");
}
(var first, var last) = FullName();
You can even use a single var declaration:
var (first, last) = FullName();
More on destructuring tuples in the official documentation.