Enum.GetName का उपयोग करके किसी Enum मान का स्ट्रिंग प्रतिनिधित्व प्राप्त करता है।
इसके दो पैरामीटर हैं -
-
टाइप करें -गणना प्रकार
-
ऑब्जेक्ट - गणना का मूल्य
निम्नलिखित एक उदाहरण है -
उदाहरण
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);
}
} आउटपुट
Motorbike