Back to course

Enums (Enumerations)

C# Zero to Hero: Comprehensive Programming Masterclass

Working with Enums

An enum is a special "class" that represents a group of constants (unchangeable variables).

Example

csharp enum Level { Low, Medium, High }

Level myVar = Level.Medium;

Why use Enums?

  • Code readability.
  • Typesafety (prevents passing invalid integers for a setting).