Break Statement –
we use break statement for “jump out of loop” the example of the break
statement is given below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i
<= 4; i++)
{
if (i == 3)
{
break;
}
Console.ReadLine( "The
number is"+i );
}
}
}
}
Output:
The number is 0
The number is 1
The number is 2
Continue Statement
– we use continue statement for “jump over one iteration” the example of the
continue statement is given below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
for (int i = 0; i
<= 4; i++)
{
if (i == 3)
{
continue;
}
Console.ReadLine( "The
number is"+i );
}
}
}
}
Output :
The number is 0
The number is 1
The number is 2
The number is 4
No comments:
Post a Comment