在研究了如何突破次级循环之后
while (true) { // Main Loop
for (int I = 0; I < 15; I++) { // Secondary loop
// Do Something
break; // Break main loop?
}}大多数人建议调用“ goto”功能,
如以下示例所示:
while (true) { // Main Loop
for (int I = 0; I < 15; I++) { // Secondary Loop
// Do Something
goto ContinueOn; // Breaks the main loop
}}ContinueOn:然而; 我经常听到'goto'声明是不好的做法。下图完美地说明了我的观点:

goto语句实际上有多糟糕,为什么?
有没有比使用“ goto”语句更有效的方法来打破主循环?
九州编程
Helenr
随时随地看视频慕课网APP