Setting the Numeric Value of Enumerator Members - CSharp Custom Type

CSharp examples for Custom Type:Enum

Description

Setting the Numeric Value of Enumerator Members

Demo Code

using System;//from  w w w  . jav  a  2s  .c  o  m

public class MainClass
{
   enum Month
   {
      January = 1,
      February = 2,
      March = 3,
      April = 4,
      May = 5,
      June = 6,
      July = 7,
      August = 8,
      September = 9,
      October = 10,
      November = 11,
      December = 12
   }
   struct birthday
   {
      public Month bmonth;
      public int   bday;
      public int   byear;
   }
   public static void Main()
   {
      birthday MyBirthday;
      MyBirthday.bmonth = Month.August;
      MyBirthday.bday = 11;
      MyBirthday.byear = 1981;   // This is a lie...
      System.Console.WriteLine("My birthday is {0} {1}, {2}", MyBirthday.bmonth, MyBirthday.bday, MyBirthday.byear);
   }
}

Result


Related Tutorials