C# Enumeration Example

  • C#
  • 1 min read

An enumeration is set of named constants of distinct value type called enumerator in C#. Every enumeration has an underlying type, which can be any data type like integer, long, short, etc. except for char type. The syntax of an enumeration in C# is the following:


[attributes] [modifiers] enum identifier
[:base-type] {enumerator-list};

C# Enumeration Example

using System;

namespace EnumeratedConstants
    class EnumeratedConstants
        enum Temperature
            MaxCold = 0,
            MaxFreezingPoint = 31,
            NormalWeather = 50,
            SwimmingWeather = 62,
            BoilingPointWeather = 222,
        static void Main(string[] args)
            System.Console.WriteLine("Max Freezing point of water: {0}",
            System.Console.WriteLine("Boiling point weather of water: {0}",


Max Freezing point of water: 31
Boiling point weather of water: 222

See also: