|
-
Sep 28th, 2009, 11:37 PM
#1
Thread Starter
Member
How do to run a loop multiple times?
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?
-
Sep 29th, 2009, 12:14 AM
#2
Re: How do to run a loop multiple times?
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.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|