The break statement
The break statement is used to break out of an iteration statement block:
int MyVariable = 0;
while(MyVariable < 10)
{
System.Console.WriteLine(MyVariable);
if(MyVariable == 5)
break;
MyVariable++;
}
The break statement
The break statement is used to break out of an iteration statement block:
int MyVariable = 0;
while(MyVariable < 10)
{
System.Console.WriteLine(MyVariable);
if(MyVariable == 5)
break;
MyVariable++;
}
System.Console.WriteLine("Out
of the loop.");
The preceding code prints the following to the console:
0
1
2
3
4
Out of the loop.
The continue statement
The continue statement returns control to the Boolean expression that controls
an iteration statement.
int MyVariable;
for(MyVariable = 0; MyVariable < 10; MyVariable++)
{
if(MyVariable == 5)
continue;
System.Console.WriteLine(MyVariable);
}
The preceding code prints the following to the console:
0
1
2
3
4
6
7
8
9
Main difference is
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.
Shobhit KaushikPosted Mar 8, 2016, 4:06 AM
Very good
Christopher AndrewsPosted Nov 18, 2015, 1:16 AM
Good Stuff. Thanks for sharing. We just checked out www.redfly.io. It is very easy to configure (just one line) with any .net app to track errors. Simple and nice!