The continue statements enables you to skip the loop and jump the loop to next iteration.
Example:
In this program, skips the loop until the current value of i reaches 6. Output is given below.
Output
6
7
8
9
10

Example:
using System;
namespace Continue_Statement
{
class Program
{
static void Main(string[] args)
{
int i = 0;
while(i<10)
{
i++;
if (i < 6)
{
continue;
}
Console.WriteLine(i);
}
Console.ReadLine();
}
}
}
namespace Continue_Statement
{
class Program
{
static void Main(string[] args)
{
int i = 0;
while(i<10)
{
i++;
if (i < 6)
{
continue;
}
Console.WriteLine(i);
}
Console.ReadLine();
}
}
}
In this program, skips the loop until the current value of i reaches 6. Output is given below.
Output
6
7
8
9
10
Comments
Post a Comment