#17 – C# continue Statement

You must use continue within a for, foreach, while, or do…while loop.
It exits only from the current iteration of the loop, and start the next iteration of the loop.

using System;


for (int i = 0; i < 10; i++)
{
    if(i % 2 == 0) continue;

    Console.Write($" {i} ");
}

Console.WriteLine();

Output:

1  3  5  7  9 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.