我正在尝试将 if 语句转换为 switch 案例(为了便于阅读)
1)我读过 switch 语句一般都很棒 - 这是真的吗? https://stackoverflow.com/questions/6097513/switch-statement-inside-a-switch-statement-c
2)声明如下:
switch (Show)
{
case Display.Expense:
if (expected.EXPENSE != true)
break;
case Display.NonExpense:
if (expected.EXPENSE == true)
break;
case Display.All:
//Code
break;
}
错误是:
控制不能从一个案例标签(“案例 1:”)转移到另一个案例标签
这是原始的 if 语句:
if ((Show == Display.All) || (expected.EXPENSE == true && Show == Display.Expense) || (expected.EXPENSE == false && Show == Display.NonExpense))
{
//Code
}