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

后端 未结 10 1147
迷失自我
迷失自我 2021-01-17 12:59

I found an empty for statement in an existing bit of code and I\'m wondering what it does and is it \"safe\". It just feels wrong.

for(;;)
{
   //some if sta         


        
10条回答
  •  自闭症患者
    2021-01-17 13:52

    All of the expressions of the for statement are optional; for example, the following statement is used to write an infinite loop:

    > for (; ; ) {
    >     // ... }
    

    Taken from MSDN

提交回复
热议问题