Reputation: 70327
In VB I can write a loop that always executes at least once. For example:
Do
[code]
Loop While [condition]
Is there a way to do that in C#?
Upvotes: 8
Views: 4106
Reputation: 8531
TopOfLoop:
// ...
if (condition)
{
goto TopOfLoop;
}
No career is complete without at least one goto
.
Upvotes: -6
Reputation: 74345
Alternatively
bool finished = false ;
while ( !finished )
{
// do something
finished = // evaluate a new foo
}
I've never been a huge fan of do/while
Upvotes: -4