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:
Suboptimal code
switch(z)
{
case1:
Console.WriteLine("1");
break;
case2:
default:
Console.WriteLine("Not specified");
break;
}
After the quick-fix
switch(z)
{
case1:
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.
Our website uses some cookies and records your IP address for the purposes of accessibility, security, and managing your access to the telecommunication network. You can disable data collection and cookies by changing your browser settings, but it may affect how this website functions. Learn more.
With your consent, JetBrains may also use cookies and your IP address to collect individual statistics and provide you with personalized offers and ads subject to the Privacy Notice and the Terms of Use. JetBrains may use third-party services for this purpose. You can adjust or withdraw your consent at any time by visiting the Opt-Out page.