1
Answer

Enum in C#

Arun Kurmi

Arun Kurmi

11y
1.4k
1
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)