while(true) versus for(;;)

kylan picture kylan · Sep 27, 2010 · Viewed 19k times · Source

Possible Duplicates:
Is “for(;;)” faster than “while (TRUE)”? If not, why do people use it?
for ( ; ; ) or while ( true ) - Which is the Correct C# Infinite Loop?

Is there any appreciable difference between while(true) (or while(1)) and for(;;)? Would there be any reason to choose one over the other?

Answer

SLaks picture SLaks · Sep 27, 2010

With optimizations enabled, they will compile identically.

You should use whichever one you find more readable.