Gets the string representation of an Enum value using the Enum.GetName.
It has two parameters −
Type − Enumeration type
Object − Value of an enumeration
The following is an example −
Example
using System;
class Demo {
enum Vehicle {
Car,
Motorbike,
Truck,
Bicycles
};
static void Main() {
// Usig GetName to get the string representation of enum type
string res = Enum.GetName(typeof(Vehicle), Vehicle.Motorbike);
// Displaying
Console.WriteLine(res);
}
}Output
Motorbike