Hi Programmers, welcome to new article of c#.net. This article i’ll write the programs to use Enumerator or Enum in c# console application. The Enum is distinct type that consists
of a set of named constants called the enumerator list. the constant values of enum members are integer type. it start with zero and increase by one.
Example 1 : the constant values of enum members are start from zero and increase by one Jul at 6 and Nov at 10 Respectively. we must use integer typecasting because Month.Jul enumerator type. See below image.

Example 2 : Enum.GetNames(typeof(Month)) .the Enum class provides the base class for enumerations. it can call GetNames method. it retrieves name of the constant
in the specified enumeration and the typeof operator returns name of the type or type parameter. i passed month enum inside typeof. See below image.

Example 3 : We can explicitly specify Constant values.In Jul , i put the value 9. see below image.

Use Directly of the below codes.
Example 1 :
using System;
namespace ConsoleApp9
{
class Program
{
public class EnumMonth
{
enum Month { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec };
static void Main(string[] args)
{
int i = (int)Month.Jul;
int j = (int)Month.Nov;
Console.WriteLine("Jul = {0}", i);
Console.WriteLine("Nov = {0}", j);
}
}
}
}
Example 2 :
using System;
namespace ConsoleApp9
{
class Program
{
public class EnumMonth
{
enum Month { Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec };
static void Main(string[] args)
{
string[] str = Enum.GetNames(typeof(Month));
int i = 0;
foreach(string s in str)
{
Console.WriteLine(s);
i++;
}
Console.WriteLine("i value {0} " , i);
}
}
}
}
Happy Coding…Thanks.