How to check whether the loop is completed or not

Hi,
I have to search all product and i am done this by counter now i want to check whether the loop is completed or not if completed (what is the condition in if ) i take another action.

how should i done.

Hi, if your refering to errors. Try to add your loop into try catch.
//If not, try to add this expression to your if else “arrayVariable.Count = counter”.

you should have another counter inside for loop and then can have if condition Counter inside for loop and the counter you got from search all product is equal then it is completed.

I just want to be clear what you are trying to achieve. You want to loop through a list ‘products’ and do something to them. If a condition is true you want to break out of the loop?

There are two ways to do this. Either use a foreach(product in products) then do something on each product and finally have an if (something) break, to exit the looping.

If you want the index of each item you can do foreach(i in Enumerable.Range(products.Count)) and use the same method to break.