Search This Blog

Thursday, December 5, 2013

Enum type c# example

C# > Types > enum

Enum is s type that contains of a set of named constants called the enumerator list.
By default the first enumerator has the value 0, and the value of each successive enumerator is increased by 1.

Example:

A.

enum SomeMonths { January, February, March };
enum OtherMonths { April = 1, May }; //Enumerators can use initializers to override the default values

int v = (int)SomeMonths.January; // 0
v = (int)OtherMonths.May; // 2


B. String Enum