Skip to end of metadata
Go to start of metadata

Part 13 - Enumerations

Definition: Enumeration


A set of name to integer value associations.

Declaring an Enumeration

Enumerations are handy to use as fields and properties in classes.

declaring an enum

Enumerations are also handy in preventing "magic numbers", which can cause unreadable code.

Definition: Magic Number


Any number outside of -1, 0, 1, or 2.

Enumerations technically assign an integer value to each value, but that should generally be abstracted from view.

declaring an enum

is the same as

declaring an enum



Except in special cases, do not assign numbers.


  1. Think of another good instance of using enums.

Go on to Part 14 - Exceptions

  • No labels