Difference b/w Break and continue statement
Using break statement,you can 'jump out of a loop' whereas by using
continue statement, you can 'jump over one iteration' and then resume your loop
execution .
Eg. Break Statement Eg.
Continue Statement
using
System; using System;
using System.Collections; using
System.Collections;
using System.Linq; using
System.Linq;
using System.Text; using
System.Text;
namespace break_example { namespace
continue_example {
Class brk_stmt {
Class cntnu_stmt {
public static void main(String [] args) { public
static void main(String [] args) {
for( int i=0; i<=5; i++) {
for( int i=0; i<=5; i++) {
if ( i==4) {
if ( i==4) {
break; continue;
}
}
Console.ReadLine( “The number is”+i ); Console.ReadLine(
“The number is”+i);
}
}
}
}
}
}
}
}
Output
Output
The number is 0; The
number is 0;
The number is 1; The
number is 1;
The number is 2; The
number is 2;
The number is 3; The
number is 3;
The number is 5;