c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
c# .net

How to create Enumerations in asp.net c#?

| | ASP-NET , Console , CSharp

The purpose of using enumeration is to improve readability by enabling us to use meaningful symbols instead of numeric values. The value of variable is an integer,it is easy to output the name of the symbol rather then its value.

enum Courses:int{computer_science,Mechanical_engineering,Electrical_engineering,Marine_Engineering};
static void Main(string[] args)
        {
            try
            {
                Courses Coursename = Courses.Electrical_engineering;
                Console.WriteLine("{0}", Coursename);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            Console.ReadLine();
        }

Output:

Electrical_Engineering