---
title: "Enumeration in C#"  
description: "Enumeration is a way to declare named constant in c#"  
author: "Anupam Mishra"  
published: 2015-12-15  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/11950/enumeration-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Enumeration in C#

Enumeration is a way to declare named [constant in c#](https://www.mindstick.com/interview/33896/difference-between-static-readonly-and-constant-in-c-sharp). Enumeration is declared by enum [keyword](https://yourviews.mindstick.com/view/87345/explained-the-importance-of-keyword-traffic) in C#. Enumeration [values](https://www.mindstick.com/forum/159360/how-to-write-sql-query-to-join-comma-separated-values) are not using in inheritance. In enumeration each one are stands for an [integer](https://www.mindstick.com/forum/160726/roman-to-integer) value. The value of first element symbol is represent is 0.\

The syntax of Enumeration is:

```
 Enum<enum_name>{
 enumeration_element_list; }
```

\

For example,

> ##### enum Month{JAN,FEB,MAR,APR,MAY,JUN,JULY,AUG,SEP,OCT,NOV,DEC};
>
> You can [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) the element of enumeration is using (.)Dot [operator](https://www.mindstick.com/blog/144/union-intersection-and-except-operator-in-sql-server) (

enum.Select_values).

In above example, using in [c# program](https://www.mindstick.com/forum/157401/c-sharp-program-to-find-all-the-divisible-numbers-by-7-which-are-less-than-100) as:

\

```
namespace Enumeration1{    class Program    {        enum Month        {            JAN, FEB, MAR, APR,MAY, JUN, JULY, AUG, SEP, OCT, NOV, DEC        };        static void Main(string[] args)        {            //Acessing enum elements              Month mon = Month.DEC;   //integer vvalue =11;            Console.WriteLine(mon);            Month mm = Month.NOV;//integer value=10;            if (mm == Month.NOV)            {                Console.WriteLine("This is Month of November");            }            string value = "JAN";            //Parsing values and checking values in month            Month mmm = (Month)Enum.Parse(typeof(Month), value);            if (mmm == Month.JAN)            {                Console.WriteLine("Equals JAN.");            }            Console.ReadKey();        }    }}
```

**Output:**

```

```

\

If you want to accept some input anywhere and checking to enum constant it is

exists or not then we using parsing in C#.

enums enhance clarity and reduce the probability of invalid constants. We use

them to represent constant values such as integers in a consistent way. enums are

checked by the compiler. It is a good idea to avoid magic constants and numbers.

Instead, prefer a self-documenting enum type.

##### *You can also read these related post*

[https://www.mindstick.com/blog/88/enumeration-in-c-sharp](https://www.mindstick.com/blog/88/enumeration-in-c-sharp)

---

Original Source: https://www.mindstick.com/articles/11950/enumeration-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
