Chapter 6. Enumerations

Enumerations bridge the gap between numbers and objects. More than a numerical ID, less than a struct, they fill that niche where you want a well-understood name without any extra baggage. You can think of them as (mostly) type-safe constants.

Enumerations also provide type-safe functionality for flags.

Declare an Enumeration

Get C# 4.0 How-To now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.