Thursday, September 20, 2012

How to write a simple switch case in C#.Net 2008

using System;
class Program
{
  static void Main(string[] args)
  {
    int i;

    i = 0;
    Console.WriteLine("Enter any number: ");
    i = Convert.ToInt32(Console.ReadLine());
    switch (i)
    {
      case 1:
              Console.WriteLine("One");
              break;
      case 2:
              Console.WriteLine("TWO");
              break;
      case 3:
              Console.WriteLine("Three");
              break;
      default:
         Console.WriteLine("invalid Number");
         break;
    }
    Console.ReadLine();
  }
}

No comments: