The source code to demonstrate the GetTypeCode() method of Enum class is given below. The given program is compiled and executed successfully.
using System;
class Sample
{
enum Colors { RED=0,GREEN=1,YELLOW=3,WHITE=4,BLACK=5};
enum Directions { EAST=0,WEST=1,NORTH=2,SOUTH=3};
//Entry point of Program
static public void Main()
{
string type = "";
Colors color = Colors.RED;
Directions direction = Directions.NORTH;
type = color.GetTypeCode().ToString();
Console.WriteLine(type);
type = direction.GetTypeCode().ToString();
Console.WriteLine(type);
}
}
Program:
The source code to demonstrate the GetTypeCode() method of Enum class is given below. The given program is compiled and executed successfully.
Output: