0 votes
in C Plus Plus by

How to get index of element in foreach loop

1 Answer

0 votes
by

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

...