Is goto ok for breaking out of nested loops?

后端 未结 10 1917
忘掉有多难
忘掉有多难 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:18

    Unacceptable in C#.

    Just wrap the loop in a function and use return.

    EDIT: On SO, downvoting is used to on incorrect answers, and not on answers you disagree with. As the OP explicitly asked "is it acceptable?", answering "unacceptable" is not incorrect (although you might disagree).

提交回复
热议问题