C#

C#

Made by DeepSource

default case should always occur at last in a switch statement CS-R1121

Anti-pattern
Major

The default case in a switch statement specifies the logic to execute when no provided cases match the input. Ideally it should be placed at last as it specifies what to do as a "last" resort. Therefore, consider placing it appropriately.

Bad Practice

switch (i)
{
    default:
        // ...
        break;

    // rest of the cases
}

Recommended

switch (i)
{
    // cases

    default:
        // ...
        break;
}