enum
A value type that defines a fixed set of named constants, such as enum Status { Pending, Shipped, Delivered }.
In more detail
Each named constant has an underlying integer value, starting from 0 by default. Switch expressions over an enum are checked for exhaustiveness, so adding a member flags every switch that ignores it.
Related terms
- value type — A type whose variables hold the data itself, so assigning one to another copies the whole value.
- switch expression — A switch construct that produces a value, with one arm per case and no fall-through between them.
- CS8509 — The C# compiler warning that a switch expression does not handle all possible input values, naming one that no arm matches.
Taught in
- The C# Language: Types, Variables, and Flow Control — Modern .NET Core, C# & Enterprise Microservices
- Records, Pattern Matching, and Modern C# — Modern .NET Core, C# & Enterprise Microservices