Arun Kurmi

Arun Kurmi

  • NA
  • 104
  • 101.8k

Enum in C#

Mar 24 2013 5:11 AM
hi Friends,

What are wrong in this Code.It will give an Exception "Input string was not in correct format"


using System;

namespace Test
    {
   class Program
            {
   enum EnumColor:
   int{
       Red=0,Green=1,Blue=2
};
static void Main(string[]args)
                    {
   Console.WriteLine("Please Enter a Color Name");
int x=Convert.ToInt32(Console.ReadLine());
switch(x)
   {
   case (int)EnumColor.Red:
   {
   Console.WriteLine("Your Choise is Red");
break;
}
case (int)EnumColor.Green:
   {
   Console.WriteLine("Your Choise is Green");
break;
}
case (int)EnumColor.Blue:
   {
   Console.WriteLine("Your Choise is Blue");
break;
}
}
}
}
}

Answers (1)