This Angular tutorial helps you get started with Angular quickly and effectively through many practical examples.

Continue and Break Statement


In C#, the continue and break statements are used to control the flow of loops. Here's how they work and how you can use them within loops.

Continue Statement

The continue statement skips the current iteration of the loop and moves to the next iteration.

Example

class Program
{
    static void Main(string[] args)
    {
        for (int count = 0; count < 10; count++)
        {
            if (count == 3)
            {
                continue;
            }
            Console.WriteLine("The number is " + count + "");
        }
        Console.ReadKey();
    }
}

Output

Continue and Break Statement in C#

Break Statement

The break statement terminates the loop immediately and transfers control to the statement that follows the loop.

Example

class Program
{
    static void Main(string[] args)
    {
        for (int count = 0; count < 10; count++)
        {
            if (count == 3)
            {
                break;
            }
            Console.WriteLine("The number is " + count + "");
        }
        Console.ReadKey();
    }
}

Output

Continue and Break Statement in C#
Next