Set initial value for the first element in an enum type in CSharp
Description
The following code shows how to set initial value for the first element in an enum type.
Example
/*from w ww. j a v a2 s .c o m*/
public class MainClass
{
enum Planets
{
Mercury = 1,
Venus,
Earth,
Mars,
Jupiter,
Saturn,
Uranus,
Neptune,
Pluto
}
public static void Main()
{
System.Console.WriteLine("Position of Earth = " +
(int) Planets.Earth);
System.Console.WriteLine("Planets.Earth = " +
Planets.Earth);
}
}
The code above generates the following result.