Is it possible to "seek" through an loop? Based on certain conditions, I want to do a "continue in place," to fast forward through a loop. Like this:
for(var thing in things) { // Do stuff if(something) { // Move iteration forward until the iteration object ("thing") meets the right condition while(true) { // Move the iteration forward...somehow [Missing code goes here] if(thing.Property == somevalue) { break; } } } // Do more stuff on the new value of "thing" } I could use continue, but I don't want to go back to the top of the loop. I want to cycle forward through the objects in the enumerator, then just pick up where I left off.
I'm guessing this is not possible. If not, what would be the best logic to emulate what I want to do.
thingscollection before iteration?forloop instead, it's easy (and dangerous) to adjust the loop counter at any point in the loop. If you have anIEnumerator, just callMoveNext()until your condition is hit.thingsobject.. if it's a datatable or dataset you could just use the.Selectmethod to filter what you need then you will have no need to do all the forward seekingwhile(true)in code