O'Reilly logo

Illustrated C# 2012 by Daniel Solis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C H A P T E R  11

Enumerations

Enumerations

An enumeration, or enum, is a programmer-defined type, such as a class or a struct.

  • Like structs, enums are value types and therefore store their data directly, rather than separately, with a reference and data.
  • Enums have only one type of member: named constants with integer values.

The following code shows an example of the declaration of a new enum type called TrafficLight, which contains three members. Notice that the list of member declarations is a comma-separated list; there are no semicolons in an enum declaration.

  Keyword      Enum name                   enum TrafficLight     {        Green,     Comma separated—no semicolons        Yellow,   ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required