ReSharper 2017.2 Help

Code Inspection: Redundant empty default switch branch

In C#, you do not have to include the default section in switch statements. If no case sections were executed, and there is no default section specified, control is transferred outside a switch statement.

ReSharper considers the empty default branch redundant and suggests removing it to improve the code readability.

Suboptimal codeAfter the quick-fix
switch (x) { case 1: Console.WriteLine(x); break; /*...*/ default: break; }
switch (x) { case 1: Console.WriteLine(x); break; /*...*/ }
Last modified: 12 October 2017

See Also