Mat*_*ero 2 c# linq ienumerable plinq
我有以下代码:
line.Split(' ').AsParallel().ForAll(word =>
{
// How to get element index?
}
Run Code Online (Sandbox Code Playgroud)
如何获得当前元素的索引?可能吗?
有一个超载Select,您可以访问索引。
line.Split(' ')
.AsParallel()
.Select((w, i) => new { Index = i, Word = w })
.ForAll(x => ...);
Run Code Online (Sandbox Code Playgroud)