Set initial Enum Values in CSharp

Description

The following code shows how to set initial Enum Values.

Example


 /*w  w w  .ja  v a2s . com*/
public class EnumValues
 {
    // declare the enumeration
    enum Temperatures
    {
       WickedCold = 0,
       FreezingPoint = 32,
       LightJacketWeather = 60,
       SwimmingWeather = 72,
       BoilingPoint = 212,
    }

    static void Main( )
    {

       System.Console.WriteLine("Freezing point of water: {0}",
          (int) Temperatures.FreezingPoint );
       System.Console.WriteLine("Boiling point of water: {0}",
          (int) Temperatures.BoilingPoint );
    }
 }

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