Cags
Well-known member
I was recently browsing through a book on C# 2.0 and came across an example of using a for loop to create an infinite loop. Im not sure why youd want to, incidently neither was the book, it just listed it incase you came across it. But has anyone ever come across this syntax.
[edit]I used the code tags because the cs tags couldnt cope the for statement (it tried to load a picture). Also note its not C# 2.0 specific, it does work in 1.1.[/edit]
Code:
for(;;)
{
// do something
// obviously youd want to check for an exit clause
}
// just for clarification purposes c# evaluates all the statements as true,
// thus producing the same outcome as this
while(true)
{
// do something
// obviously youd want to check for an exit clause
}