Home » C#.Net Enum(Enumeration) Tutorial with Examples

C#.Net Enum(Enumeration) Tutorial with Examples

C#.Net Enum(Enumeration) Tutorial with Examples

Today, We want to share with you C#.Net Enum(Enumeration) Tutorial with Examples.
In this post we will show you C# Enum(Enumeration) with Example, hear for Enum in C#.Net with example we will give you demo and example for implement.
In this post, we will learn about How To Create And Use C# Enums with an example.

Introduction: Enum in C#.Net

In this post, we will learn about Enum in C#.Net with an example.An enumeration is a set of named integer constants along with some value. It is declared using the enum keyword.

Read Also:  SQL left outer join Examples

C# enumerations are value data type. i.e. enumeration contains its own values and cannot inherit or cannot pass inheritance.

The default underlying type of the enumeration member is int. By default, the first enumerator has the value 0, and the value of each successive enumerator is increased by 1.

How To Create And Use C# Enums

Now, Create Console Application in Visual Studio and write below line of C# Enum Example code.

Read Also:  Check if element Exists on the Page using jQuery

using System;
using System.Collections;

namespace ConsoleDemo
{
    class Program
    {
        public enum WeekDays
        {
            Sunday = 1, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
        }

        static void Main(string[] args)
        {
            Console.WriteLine("Day of week {0} {1}", (int)WeekDays.Sunday, WeekDays.Sunday);
            Console.WriteLine("Day of week {0} {1}", (int)WeekDays.Monday, WeekDays.Monday);
            Console.WriteLine("Day of week {0} {1}", (int)WeekDays.Tuesday, WeekDays.Tuesday);
            Console.WriteLine("Day of week {0} {1}", (int)WeekDays.Wednesday, WeekDays.Wednesday);
            Console.WriteLine("Day of week {0} {1}", (int)WeekDays.Thursday, WeekDays.Thursday);
            Console.WriteLine("Day of week {0} {1}", (int)WeekDays.Friday, WeekDays.Friday);
            Console.WriteLine("Day of week {0} {1}", (int)WeekDays.Saturday, WeekDays.Saturday);
            Console.ReadLine();
        }
    }   
}

Read :

Read Also:  Laravel 6 Print Last Query(Debugging Queries)

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Enumerations in c# .NET Example.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.


Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Remove # from URL VueJS Example
  2. Read Also:  How to Open URL in New Window using jQuery?
  3. Read Also:  AngularJS Simple Login Form
  4. Read Also:  Remove Duplicate Objects from Array Jquery Example
  5. Read Also:  jquery Count Number of characters in string input
  6. Read Also:  Angularjs ng-keypress Event Handling Directive
  7. Read Also:  PHP Ajax dynamic Progress Bar for PHP AJAX File Upload
  8. Read Also:  AngularJS Simple Login Form
  9. Read Also:  How to Open URL in New Window using jQuery?
  10. Read Also:  PHP Ajax dynamic Progress Bar for PHP AJAX File Upload

Leave a Comment

Your email address will not be published. Required fields are marked *