break statement ends the execution of the body of an iteration or switch statement: - CSharp Language Basics

CSharp examples for Language Basics:break

Description

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

Demo Code

using System;//w w w  .ja va  2s.c om
class Test
{
   static void Main(){
      int x = 0;
      while (true)
      {
         if (x++ > 5)
            break ;      // break from the loop
         }
         // execution continues here after break
      }
}

Related Tutorials