Break and Continue Statement in C#:-
A break statement is used to terminate the loop manually using the condition. by default loop statement will be terminated when condition will false but using break statements , we can manually exit from the loop.
A break statement is used to terminate the loop manually using the condition. by default loop statement will be terminated when condition will false but using break statements , we can manually exit from the loop.
Example of Break Statements:-
for loop, step is 10 but it will be terminated with 2 steps.
for(int i=1;i<=10;i++)
{
if(i==3)
break;
Console.WriteLine(i);
}
o/p 1 2
Continue:- It is used to skip the data based on condition, Loop will process after continuing statement.
for(int i=1;i<=10;i++)
{
if(i==3)
continue;
Console.WriteLine(i);
}
o/p 1 2 4 5 6 7 8 9 10
POST Answer of Questions and ASK to Doubt