CSharp - Statement break statement

Introduction

The break statement ends the execution of the body of an iteration or switch statement:

Demo

using System;
class MainClass//ww w . j a v  a 2 s  . c o m
{
   public static void Main(string[] args)
   {
         int x = 0;
         while (true)
         {
           Console.WriteLine("before break:"+x);
           if (x++ > 5)
             break ;      // break from the loop
           Console.WriteLine("after break:"+x);
         }
         Console.WriteLine("execution continues here after break");
   }
}

Result