【发布时间】:2012-03-02 15:57:44
【问题描述】:
我有这样的代码:
if (pref_const == Constants.PREF_PricingTypesFormWidth)
{
a = 2;
b = 3;
DoneFlag = true;
}
if (pref_const == Constants.PREF_PricingTypesFormTop)
{
a = 4;
b = 2;
DoneFlag = true;
}
......
if(!DoneFlag)//replacing of default-section in switch-statement
{
//DoSthng
}
还有许多其他的 if 语句。不要问我为什么不使用 switch 语句。 那么,有没有办法减少 DoneFlag 变量呢?
【问题讨论】:
-
您要重用还是减少
DoneFlag?我不太明白你的问题。 -
我没有得到你的问题。最后一句应该是什么意思?
-
如果您提出的问题对读者的要求很高,只是为了理解这个问题,如果没有人回答,请不要感到惊讶。
-
没有 switch,没有 else if,你到底想做什么?
-
好的,我必须回答(下)。如果你对多态性做一点研究,你就会得到答案。
标签: c# if-statement switch-statement