O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

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

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 ...

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