What is an enumeration?

An enum (enumeration) is a value type that consists of a collection of named constants. Using enums creates a modular design that enhances clarity and reduces the probability of invalid constants.

Enums are generally defined directly in the namespace (outside of any class).

Example

In the following example, an enumeration is declared and the value is assigned. The output is displayed using the defined Output() method.

Get hands-on with 1200+ tech skills courses.