gpt4 book ai didi

c# - If Condition inside 开关盒

转载 作者:太空狗 更新时间:2023-10-29 17:29:19 26 4
gpt4 key购买 nike

<分区>

我正在尝试将 if 语句转换为 switch case(为了可读性)

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;
}

错误是:

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

这是原始的 if 语句:

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

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com