Foreach index


Is there a way to get the index in the foreach loop? Also ability to increment or decrement the index as needed. Running into error conditions during the loop which require the loop to run again.

I was hoping for something like this in a regular for loop where you have access to the variable ‘i’.
for (int i = 0; i < fibarray.Length; i++)


Hi @sirwittles,

Yes, it’s possible. Please check it.

Main.xaml (6.5 KB)


Why not use the While-loop. You can create the i variable(count), new variable int i = 0.
While i < fibarray.Length
i = i + 1



In UiPath, it’s also possible to use the Do While activity to achieve this matter:

Main.xaml (7.0 KB)


Works a treat. Thanks @acaciomelo!