Jump of a while loop with goto statement in CSharp

Description

The following code shows how to jump of a while loop with goto statement.

Example


using System;//from w w w .j av  a  2  s  .  co  m

public class MainClass {     

  static void Main(string[] args)
  {
    int a = 0;

    while (a < 10)
    {
      if (a == 5)
        goto cleanup;
    }
  cleanup :

    Console.WriteLine(a);
  }
}




















Home »
  C# Tutorial »
    C# Language »




C# Hello World
C# Operators
C# Statements
C# Exception