I read the lines from a textfile into a string array and then I use a foreach loop on the string array. I want to go through the same string array again after the loop reach the end of the string array. How do I accomplish this?
Printable View
I read the lines from a textfile into a string array and then I use a foreach loop on the string array. I want to go through the same string array again after the loop reach the end of the string array. How do I accomplish this?
First up, do you really need to loop through the same data twice? Maybe you do but maybe you don't. Can you possibly perform two tasks inside the loop you already have, rather than looping again?
If not then you simply need two loops. Either you need two distinct For Each loops that both loop through the array or else you need to nest the For Each loop inside another For loop, whichever is more appropriate. The second option will only work if your doing the same thing to each element both times. In that case you might also consider putting the loop inside a method and calling that twice.