How to Skip Iteration of a foreach loop in C# ?


This content was proof-read by Grammarly. You can Try Grammary for FREE

When using C# programming language , there are times when you might want to skip over the iteration based on some condition and jump over to the next iteration.

How to Skip Iteration of a foreach loop in C# ?

continue keyword comes to your rescue for this use case. When you want to skip the processing of current iteration and jump to the next iteration, use the continue keyword as shown below.

foreach (int item in Items)   
{                              
    if (item < 0)             
    {                           
        continue;   // Skip the Iterations
    }
}
Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

%d bloggers like this: