continue

A statement that skips the rest of the current loop repetition.

What does continue do in C#?

continue — A statement that skips the rest of the current loop repetition.

class NumberFinder
{
    int FirstOdd(int[] numbers)
    {
        foreach (int number in numbers)
        {
            if (number % 2 == 0)
            {
                continue;
            }

            return number;
        }

        return -1;
    }
}

Level: Apprentice · More C# terms at this level

Updated

In other subjects