Switch upon int type in CSharp

Description

The following code shows how to switch upon int type.

Example


    using System;
  public class MainClass
  {//  w w  w .  ja  v a  2 s.  c  om
    static void Main(string[] args)
    {
      int a = 0;
      Console.ReadLine();

      switch (a)
      {
        case 1:
          Console.WriteLine("One");
          break;
        case 2:
          Console.WriteLine("Two");
          break;
        default:
          Console.WriteLine("?");
          break;

      }
    }
  }




















Home »
  C# Tutorial »
    C# Language »




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