Latest web development tutorials

C # continue statement

C # loop C # loop

Continue statement in C # a bit like a breakstatement. But it is not forced to terminate, continue will skip the current code in the loop, forced to start a next cycle.

For thefor loop,continue statement causes the condition to perform the test cycles and incremental part. Forwhile and do ... whileloop, continue statement causes program control returns to the conditional test.

grammar

Continue in C # syntax statements:

continue;

flow chart

Continue statement in C #

Examples

using System;

namespace Loops
{
    
    class Program
    {
        static void Main (string [] args)
        {
            / * Local variable definitions * /
            int a = 10;

            / * Do loop execution * /
            do
            {
                if (a == 15)
                {
                    / * Skip iteration * /
                    a = a + 1;
                    continue;
                }
                Console.WriteLine ( "a value: {0}", a);
                a ++;

            } While (a <20);
 
            Console.ReadLine ();
        }
    }
} 

When the above code is compiled and executed, it produces the following results:

a value of: 10
a value of: 11
a value of: 12
a value of: 13
a value of: 14
a value of: 16
a value of: 17
a value of: 18
a value of: 19

C # loop C # loop