How to merge two case statements in one switch statement

c#, c++

Solution

You just need `break;` for your current code like:

switch (code)
{
    case 'A':
    case 'a':
        break;
    // to do 
    default:
        // to do 
        break;
}

but if you are comparing for upper and lower case characters then you can use `char.ToUpperInvariant` and then specify cases for Upper case characters only:

switch (char.ToUpperInvariant(code))
{
    case 'A':
        break;
    // to do 
    default:
        // to do 
        break;
}

Problem

``` switch(code) { case 'A': case 'a': // to do default: // to do } ``` Is there any way to merge the two "case" statements together?

Original source