CS8509
The C# compiler warning that a switch expression does not handle all possible input values, naming one that no arm matches.
In more detail
Treat it as a to-do list: when a new enum member is added, every switch expression that ignores it lights up in the build. The alternative, a discard arm, hides the problem.
Related terms
- exhaustiveness — The property of a switch expression whose arms cover every possible input value, which the compiler checks for you.
- switch expression — A switch construct that produces a value, with one arm per case and no fall-through between them.
- enum — A value type that defines a fixed set of named constants, such as enum Status { Pending, Shipped, Delivered }.
- compiler warning — A message from the compiler or an analyzer about code that builds but is probably wrong, identified by a code such as CS8602.
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