.net increment index in for each code example
Example: how to get foreach index c#
// foreach with a "manual" index
int index = 0;
foreach (var item in collection)
{
DoSomething(item, index);
index++;
}
// normal for loop
for (int index = 0; index < collection.Count; index++)
{
var item = collection[index];
DoSomething(item, index);
}