How to get index of element in foreach loop
Below is the code to get index of element when we are working on foreach loop
int z = 0;
foreach (Object i in collection)
{
// set of statements
// Some values
z++;
}
From above code we will get the value in variable z as index value