Possible Duplicate:
What does “for(;;)” do in C#?
what does
for (; ; )
{
// do something
}
mean in c#?
Isn't there supposed to be (initializer, condition, iterator) ?
I saw an example in a book that uses nothing inside the contents of the for loop.
That would create an unconditional (infinite) loop which has no initializer or iterator.
same as
while(true)
{
...
}
You'll have to use break; to get out of the loop.
At warning level 4 compilers complain about conditional expressions that always evaluate to true, such as while(1) or while(true).
So a common way to suppress the compiler warnings for that is to use for (;;) blocks.
(Im not saying its a good practice), but if you have to create code that compiles at warning level 4 its a habit to use for (;;) instead of while (true).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With