mujiansu / morelinq

Automatically exported from code.google.com/p/morelinq
Apache License 2.0
0 stars 0 forks source link

ForEach should optionally take an index #101

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Just like Select does.

list.ForEach((x, i) => {x.Id = i});

Original issue reported on code.google.com by a...@milyli.com on 7 May 2015 at 7:05

GoogleCodeExporter commented 8 years ago
MoreLINQ has Index[1][2] already that solves this problem once and for all. You 
can compose it before ForEach like this to get the index:

list.Index().ForEach(e => Console.WriteLine("list[{0}] = {1}", e.Key, e.Value));

[1] 
https://code.google.com/p/morelinq/source/browse/MoreLinq/Index.cs?name=1.0&r=9e
a817b7a5aa0983230979259523e663d356e04f
[2] https://www.nuget.org/packages/MoreLinq.Source.MoreEnumerable.Index/

Original comment by azizatif on 7 May 2015 at 11:54

GoogleCodeExporter commented 8 years ago

Original comment by azizatif on 7 May 2015 at 11:54