![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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
Advertisements