Assign int value to the first element in an enum : Enum base type : Data Type C# Examples


C# Examples » Data Type » Enum base type »

 

Assign int value to the first element in an enum









    
enum  Planets
{
    Mercury  =  1,
    Venus,
    Earth,
    Mars,
    Jupiter,
    Saturn,
    Uranus,
    Neptune,
    Pluto
}

class  MainClass
{

    public  static  void  Main()
    {

        System.Console.WriteLine("Position  of  Earth  =  "  +(int)  Planets.Earth);

        System.Console.WriteLine("Planets.Earth  =  "  +Planets.Earth);

    }

}
    
   
  
   



Output

Position of Earth = 3
Planets.Earth = Earth


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Enum base type