我有一些需要转换的数据,为此我需要使用超过50个情况的开关条件,我需要同样的情况3次,但第三次我需要50个以上的情况,并且我不想两次编写相同的代码。或许有可能做到这样的事情。
switch (example)
{
case "1":
//do something
case "2":
//do something
case "50":
//do something
//now maybe something like this
if (condition == true)
{
case "1":
//do something else than above at case "1", and so on
//now its i little bit illogical, but i neet to do the first 50 cases and then
//use the cases 1 to 50 again but with other actions
}
}
case "50"
中,您也想检查case "51"
等等吗? - Cid