Multiple cases in switch statement

I guess this has been already answered. However, I think that you can still mix both options in a syntactically better way by doing:

switch (value)
{
    case 1: case 2: case 3:          
        // Do Something
        break;
    case 4: case 5: case 6: 
        // Do Something
        break;
    default:
        // Do Something
        break;
}

Leave a Comment