The GetName() method returns the names of the constants in the Enumeration.
Here is the enum.
enum Stock { Appliance, Clothing, Footwear };Now, get the names using the Enum.GetName() method. Just set the constant and retrieve the individual name.
Enum.GetName(typeof(Stock), 1
Let us see the example now.
Example
using System;
class Demo {
enum Stock { Appliance, Clothing, Footwear };
static void Main() {
Console.WriteLine("The value of second stock category = {0}",Enum.GetName(typeof(Stock), 1));
Console.WriteLine("The value of third stock category = {0}",Enum.GetName(typeof(Stock), 2));
}
}Output
The value of second stock category = Clothing The value of third stock category = Footwear