Is goto ok for breaking out of nested loops?

后端 未结 10 1841
忘掉有多难
忘掉有多难 2021-01-18 04:33

JavaScript supports a goto like syntax for breaking out of nested loops. It\'s not a great idea in general, but it\'s considered acceptable practice. C# does not directly

10条回答
  •  天涯浪人
    2021-01-18 05:09

    int i = 0;                 
    while(i <= 10)     
    {         
        Debug.WriteLine(i);         
        i++;         
        for(int j = 0; j < 3 && i <= 5; j++)             
        {
            //Whatever you want to do
        }
     }      
    

提交回复
热议问题