在下面的C#代码片段中,我有一个嵌套的'while'循环和一个'foreach'循环,当发生某些条件时,我希望跳到下一个'foreach'项。
'
foreach (string objectName in this.ObjectNames)
{
// Line to jump to when this.MoveToNextObject is true.
this.ExecuteSomeCode();
while (this.boolValue)
{
// 'continue' would jump to here.
this.ExecuteSomeMoreCode();
if (this.MoveToNextObject())
{
// What should go here to jump to next object.
}
this.ExecuteEvenMoreCode();
this.boolValue = this.ResumeWhileLoop();
}
this.ExecuteSomeOtherCode();
}
'
continue
'会跳转到'while
'循环的开头,而不是'foreach
'循环的开头。这里是否有一个关键字可以使用,或者我只能使用我不太喜欢的goto?