Code inspection: Redundant 'case' label before default section
This inspection reports an enum case label in a switch section that already contains default: and therefore matches everything that reaches that section. The extra enum label is redundant because default already covers it.
enum State
{
Ready,
Done
}
class C
{
void M(State state)
{
switch (state)
{
default:
case State.Ready:
break;
}
}
}
enum State
{
Ready,
Done
}
class C
{
void M(State state)
{
switch (state)
{
default:
break;
}
}
}
This inspection is specific to enum switches where that section is already the catch-all branch.
13 April 2026