By 22/07/2015 12 Comments

C# Break Statement

  • By using a C# break statement we can easily exit from for, while, do while loop and switch statement, because break statement terminates the current execution of loops and switch in which it defined, than the remaining code inside loops and switch’s body will be bypassed, flow control go to the next code if available.
  • The break statement terminates loops and switch statements according by given condition, and terminates these from its normal routine.
  • When we use break statement inside nested loops than the only single loop will be terminated in which break might be defined.
  • In simple words we can say that break statement terminate or exit from loop earlier than its normal terminate condition.


using System;
namespace csharpBasic
    // Start class definition / declaration.
    class Program
        // Static main method void type declaration.
        static void Main(string[] args)
            // for loop is declared which has been designed to run 10 times.
            for (int countNumber = 1; countNumber <= 10; countNumber++)
                // if condition declaration.
                if (countNumber == 6)
                    break;  // break statement.

                  // Print countNumber varaible.
                    Console.WriteLine("Number: {0}", countNumber);

            } // End of for loop.


        } // End of main method definition. 
    } // End of class. 

    The Output will be:
    Number: 1
    Number: 2
    Number: 3
    Number: 4
    Number: 5

Next Tutorial →

← Previous Tutorial

Posted in: C# Basics, C#.NET

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .