ReSharper 2024.3 Help

Code inspection: Redundant 'case' label

Empty case sections before the default case in a switch statement do not make any sense because code corresponding to their conditions will be executed in the default case anyway. ReSharper suggests removing such empty case sections:

switch (z) { case 1: Console.WriteLine("1"); break; case 2: default: Console.WriteLine("Not specified"); break; }
switch (z) { case 1: Console.WriteLine("1"); break; default: Console.WriteLine("Not specified"); break; }

Note that empty case sections before a non-empty case section are valid and mean that the code in the non-empty case section executes for all cases that go before it.

Last modified: 08 April 2024