the break statement : Break : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Break »

 

the break statement









    

/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy

Publisher: Sybex;
ISBN: 0782129110
*/

/*
  Example4_13.cs illustrates the use of
  the break statement
*/

public class Example4_13
{

  public static void Main()
  {

    int total = 0;

    for (int counter = 1; counter <= 10; counter++)
    {
      System.Console.WriteLine("counter = " + counter);
      total += counter;
      if (counter == 5)
      {
        System.Console.WriteLine("break from loop");
        break;
      }
    }

    System.Console.WriteLine("total = " + total);

  }

}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Break