Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to return to the top of a foreach loop
Message
From
15/02/2007 12:20:47
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01185290
Message ID:
01196117
Views:
8
Hmmm ... weird. At first I thought maybe it was something screwy with the foreach (because I usually use just plain old for), so I tried it myself and I *thought* it had worked fine. That's when I posted my previous reply.

So, I tried it again, this time with a few more iterations in my loop. Lo and behold, there *is* a bug with foreach!!!! (At least I consider it a bug). It works as you would expect with a for loop (skips to the beginning of the loop and continues), but with the foreach, it totally stops and exits the loop. NOT INTUITIVE BEHAVIOR, IMHO!!

Anybody else consider this a bug?!?!?

~~Bonnie



>Bonnie,
>
>Yes, I'm saying it didn't work. There are no other loops in the code.
>
>Thanks.
>
>Linda
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform