我有这样的代码:
if(condition1)
{
break MyLabel;
}
while(true)
{
//some code here
MyLabel: if(condition2) break;
//more code here
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
标签MyLabel缺失.
怎么了?
您不能以一般方式使用标签作为goto .
如果要转到更高级别的嵌套代码,请使用标签.
例如
l1: while
l2: while
l3: while
break l1
l4: while
Run Code Online (Sandbox Code Playgroud)