C# program to demonstrate the GetTypeCode() method of Enum class
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);
}
}
Int32
Int32
Press any key to continue . . .
Table of Contents