Strange for a loop? WITH#

Possible duplicate:
In C # is for (;;) safe and what does it really do?

So, I recently stumbled upon something that I had never seen.

        for (; ; )
        {

        }

What happens when feilds remain empty?

+3
source share
3 answers

This is an endless cycle.

Somewhere inside there should be an operator break;or, possibly, an exception created so that the control passes outside the loop.

You can also achieve the same (perhaps more obvious) by doing

while (true)
{
    // do stuff
}
+13
source

This is an infinite loop, almost equivalent to a loop while(true).

break , - .

+2

.

+1

Source: https://habr.com/ru/post/1777593/


All Articles