Declaring and Using Plain Enums
Represent a fixed set of values.
A Fixed Set of Choices
Some values only ever come from a short, known list, like the days of the week. An enum names that fixed set of choices for you.
Declaring an Enum
You write enum, a name, then the allowed values inside braces. Each value is one constant member of that type.
enum Direction { north, south, east, west }All lessons in this course
- Declaring and Using Plain Enums
- Enum Values, index, and name
- Enhanced Enums With Fields and Methods
- switch Over Enums Exhaustively