An enumeration is a user-defined value type that inherits directly from the System.Enumtype. You typically use enumeration types to represent a fixed set of options such as the days of the week or the possible states of a database connection. To define an enumeration type, use the enum (C#) keyword. An
Enumeration type contains mnemonics that represent integer values; these values start at 0 and increase in steps of 1 by default. Enumerations cannot define methods, properties, or constructors. Furthermore, enumerations cannot implement interfaces, and they cannot explicitly inherit from a class or be used as a base class.
The following examples shown:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
enum color { red, green, blue,white,black,orange,pink,yellow, };
class Program
{
static void Main(string[] args)
{
Console.WriteLine((int)color.red);
Console.WriteLine((int)color.green);
Console.WriteLine((int)color.blue);
Console.WriteLine((int)color.white);
Console.WriteLine((int)color.black);
Console.WriteLine((int)color.orange);
Console.WriteLine((int)color.pink);
Console.WriteLine((int)color.yellow);
Console.ReadLine();
}
}
}
Output is display bellow.