Set base type for enum to long in CSharp

Description

The following code shows how to set base type for enum to long.

Example


// w w  w.  ja va 2s.c om
public class MainClass
{

  enum PlanetPeriods :long
  {
    Mercury = 88,
    Venus = 225,
    Earth = 365,
    Mars = 687
  }

  public static void Main()
  {

    System.Console.WriteLine("Orbital period for Mars = " +
      (long) PlanetPeriods.Mars + " days");

  }

}

The code above generates the following result.





















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var