An Intermezzo About Enums

Related to constants are enums, which are value types that contain for their members a set of named constants. A typical example of an enum is Color, as shown here:

enum Color{    Red,    Green,    Blue,}

Right inside the framework you can find quite a few enums, as well; for example, to indicate a “file open mode” when using System.IO application programming interfaces (APIs). Just like other value types, you can apply an access modifier to the type.

Note: (Trailing) Commas

Notice that an enum’s members are comma separated and not semicolon separated. Basically, they denote a list of symbolic values. A trailing comma is allowed after the last member, which is often put there so that the addition of new members to ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.