The source code to demonstrate the GetType() 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,WEST,NORTH,SOUTH};
//Entry point of Program
static public void Main()
{
string type = "";
Colors color = Colors.RED;
Directions direction = Directions.NORTH;
type = color.GetType().ToString();
Console.WriteLine(type);
type = direction.GetType().ToString();
Console.WriteLine(type);
}
}
Output:
Sample+Colors
Sample+Directions
Press any key to continue . . .
Program:
The source code to demonstrate the GetType() method of Enum class is given below. The given program is compiled and executed successfully.
Output: