How to break out of multiple loops at once in C#?

前端 未结 4 1177
遥遥无期
遥遥无期 2021-02-02 04:54

What if I have nested loops, and I want to break out of all of them at once?

while (true) {
    // ...
    while (shouldCont) {
        // ...
        while (sho         


        
4条回答
  •  时光取名叫无心
    2021-02-02 05:32

    Goto is only hideous when abused. To drop out of the innermost loop of some nesting it's acceptable. BUT... one has to ask why there is so much nesting there in the first place.

    Short answer: No.

提交回复
热议问题