C# continue statement

C# continue statement works just opposite of the C# break statement. The C# continue statement forces the control to do the next iteration of loop without executing any statement followed after the continue .

The continue keyword is normally used with a conditional statement. Following is an example of continue statement.

Example

Try It
using System;
 
namespace TutorialsLeader
{
    public class MyFirstClass
    {
        static void Main()
        {
            for (int i = 0; i < 10; i++)
            {
                if (i < 5)
                    continue; //Skip the rest of the block and continue the loop
 
                Console.WriteLine("The value of i is {0}", i); //This statement will never execute till the value of i is less than 5.
            }
        }
    }
}

continue can be used with all the loops in C#. Following is an example of continue statement with while loop.

Example

Try It
using System;
 
namespace TutorialsLeader
{
    public class MyFirstClass
    {
        static void Main()
        {
            int i = 0;
            while (i < 10)
            {
                i++; //Incrementing the value of i 
 
                if (i < 5)
                    continue;
 
                Console.WriteLine("The value of i is {0}", i);
            }
        }
    }
}

Let 's learn about the goto statement in the next section.