C# 7 tuples and lambdas

As you have observed, for:

var list = new List<(int,int)>();

One would at least expect to be able to do the following:

list.Select((x,y) => x*2 + y/2);

But the C# 7 compiler doesn’t (yet) support this. It is also reasonable to desire sugar that would allow the following:

void Foo(int x, int y) => ...

Foo(list[0]);

with the compiler converting Foo(list[0]); to Foo(list[0].Item1, list[0].Item2); automatically.

Neither of these is currently possible. However, the issue, Proposal: Tuple deconstruction in lambda argument list, exists on the dotnet/csharplang repo on GitHub, requesting that the language team consider these features for a future version of C#. Please do add your voices to that thread if you too would like to see support for this.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)