你之前的那个不叫标签,而是一个简单的全局Json+闭包
本身没有什么含义
在C#中可以这样来变通实现
Action test=()=>{
if (a > 0) { MessageBox.Show(0);return ; }
if (a > 1) { MessageBox.Show(1); return ; }
if (a > 2) { MessageBox.Show(2); return ; }
if (a > 3) { MessageBox.Show(3); return ; }
};
test();
这个标签
test:{
}
在c#是没有 break test,建议改成goto,或者switch case结构。
test: {
if (a > 0) { MessageBox.Show(0); goto test1; }
if (a > 1) { MessageBox.Show(1); goto test1; }
if (a > 2) { MessageBox.Show(2); goto test1; }
if (a > 3) { MessageBox.Show(3); goto test1; }
}
test1:
int a = 100;
test: {
if (a > 0) { MessageBox.Show(0); break test; };
if (a > 1) { MessageBox.Show(1); break test; };
if (a > 2) { MessageBox.Show(2); break test; };
if (a > 3) { MessageBox.Show(3); break test; };
};
试试这样行吗?