这是我的代码:
private void Mymethod()
{
if(animal == "Dog")
{
goto LabelMonsters;
}
//return here after goto LabelMonsters executes
if (animal == "Cat")
{
goto LabelMonsters;
}
//another return here after goto LabelMonsters executes
if (animal == "Bird")
{
goto LabelMonsters;
}
//Some long codes/execution here.
return;
LabelMonsters:
//Some Code
}
Run Code Online (Sandbox Code Playgroud)
在我的示例中,我有几个if语句,在第一次执行goto语句之后,我必须返回到我的方法下的下一步.我试过继续但不工作.执行必须持续到最后.
c# ×1