

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# Enum GetName Method
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
- Related Questions & Answers
- Provider getName() method in Java
- C# Enum IsDefined Method
- C# Enum ToString() Method
- C# Enum Parse Method
- C# Enum TryParse() Method
- C# Enum CompareTo Method
- C# Enum Equals Method
- C# Enum Format Method
- C# Enum GetNames Method
- C# Enum GetValues Method
- Can we define an enum inside a method in Java?
- Enum in Java
- Enum in C#
- Enum in C
- Enum in Python
Advertisements