Thursday, 22 August 2013

using foreach to iterate simultaneously through multiple lists (syntax sugar)

using foreach to iterate simultaneously through multiple lists (syntax sugar)

Hi is there a way to do things like this:
for (int i = 0; i < Math.Min(a.Count, b.Count); i++)
{
// Do stuff
//a[i]
//b[i]
}
with Foreach?
because it would be nice to write something like
foreach(var item1 in list1 and var item2 in list2 /* ....*/)
{
item1.use(item2);
}

No comments:

Post a Comment