Tag: 跳转

如何在C#中一次突破多个循环?

如果我有嵌套循环,而且我想一下子突破所有这些? while (true) { // … while (shouldCont) { // … while (shouldGo) { // … if (timeToStop) { break; // Break out of everything? } } } } 在PHP中, break需要一个参数来指出循环的次数。 这样的事情可以在C#中完成吗? 什么东西可怕,像goto ? // In the innermost loop goto BREAK // … BREAK: break; break; break;