What will happened if continue statement is placed in a for Loop?
Continue statement is used in c# to set control to the beginning of the loop.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i <= 10; i++)
{
Console.WriteLine (i.ToString());
continue;
Console.WriteLine("Iam never printed");
}
}
}
}
For example in the below code the line Console.WriteLine("Iam never printed"); is never executed because the control is set back to the beginning of the loop when the execution reaches the continue; stetment.
Continue statement is used in c# to set control to the beginning of the loop.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i <= 10; i++)
{
Console.WriteLine (i.ToString());
continue;
Console.WriteLine("Iam never printed");
}
}
}
}
For example in the below code the line Console.WriteLine("Iam never printed"); is never executed because the control is set back to the beginning of the loop when the execution reaches the continue; stetment.