forum

Home / DeveloperSection / Forums / If Condition inside switch case

If Condition inside switch case

Anonymous User223706-Apr-2013
Hi Everyone!

I am trying to convert an if statement to switch cases (for readability)

1) I've read switch statements are aweful in general - Is that true?

http://stackoverflow.com/questions/6097513/switch-statement-inside-a-switch-statement-c

2) The statement goes like this:

switch (Show)
                {
                    case Display.Expense:
                        if (expected.EXPENSE != true)
                            break;
                    case Display.NonExpense:
                        if (expected.EXPENSE == true)
                            break;
                    case Display.All:
                        //Code
                        break;
                }
Error is:

Control cannot fall through from one case label ('case 1:') to another

This is the original if statement:

if ((Show == Display.All) || (expected.EXPENSE == true && Show == Display.Expense) || (expected.EXPENSE == false && Show == Display.NonExpense))
{
    //Code
}

Advance Thanks

Updated on 06-Apr-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By