In this blog, I will explain you how to use the break statement in C#, It is a very simple question which is randomly ask in the interview.
Break statement is used to stop the execution of code from where you want. It means, if you want to stop or break the execution of program from any particular condition, than you need to use break statement.
Following is the simple example.
- using system.
- namespace DemoTest
- {
- class DemoClass
- {
- static void Main(string[] args)
- {
- for (int i = 0; i < 11; i++)
- {
- Console.WriteLine("Number is :" + i.ToString());
- if (i == 2)
- break;
- }
- Console.WriteLine("Out side of loop");
- Console.ReadLine();
- }
- }
- }
Hope you enjoyed the blog. Thanks for reading.

Christopher AndrewsPosted Nov 18, 2015, 1:15 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!