嗨,有没有办法做这样的事情:
for (int i = 0; i < Math.Min(a.Count, b.Count); i++)
{
// Do stuff
//a[i]
//b[i]
}
Run Code Online (Sandbox Code Playgroud)
与Foreach?
因为写一些类似的东西会很好
foreach(var item1 in list1 and var item2 in list2 /* ....*/)
{
item1.use(item2);
}
Run Code Online (Sandbox Code Playgroud)
好对不起我对某些人不够清楚,所以希望能有更好的解释
List<classA> listA = fillListA();
List<classB> listB = fillListB();
//here could be infinity many lists of sometimes diffrent T types
Run Code Online (Sandbox Code Playgroud)
现在我想执行某种ForEach因为我不喜欢用for循环做它应该简单明了很好像
foreach(var item1 in list1 and var item2 in list2 /* and ...*/)
{
item1.use(item2);
}
Run Code Online (Sandbox Code Playgroud)
AFAIK我不能修改这样一个keay词类的东西,所以我认为确定构建像Parallel.ForEach那样的迭代器,ForEach<TSource>(IEnumerable<TSource>, Action<TSource>) …