سؤال

let's say I have a foreach loop to perform some processing on List MyTypeInstanveVariable

foreach(MyType item in MyTypeInstanceVariable) {
    if (cond1) {}

    if (cond2) {}
}

If cond1 is met I want to advance to the next item in the MyTypeInstanceVariable. Now I could add a little boolean to check whether to evaluate cond2, but is there some built in command that will quickly move onto the next item? I can't use break as that would break out of the foreach loop altogether

Thanks Thomas

هل كانت مفيدة؟

المحلول

You are looking for the continue statement.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top