在下面的 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。