高手帮我看一下,下面的代码有没有逻辑错误?
if (iDigital == 0 && iOther == 0)
{
lblDigital.Text = string.Format( "0-{0} ", (18 - Out4PortCard - Out8PortCard) * 16);
lblOther.Text = string.Format( "0-{0} ", (18 - Out4PortCard - Out8PortCard) * 16);
if (iOther == 0)
{
lblOther.Text = string.Format( "0-{0} ", (18 - Out4PortCard - Out8PortCard - Dig8PortCard - Dig16PortCard) * 16);
return (18 - Out4PortCard - Out8PortCard - Dig8PortCard - Dig16PortCard) * 16;
}
else if (iDigital == 0)
{
lblDigital.Text = string.Format( "0-{0} ", (18 - Out4PortCard - Out8PortCard - Sim16PortCard) * 16);
return (18 - Out4PortCard - Out8PortCard - Sim16PortCard) * 16;
}
return (18 - Out4PortCard - Out8PortCard) * 16;
}
请说一下解决方法.
------解决方案--------------------明显有逻辑错误
{
if (iDigital == 0 && iOther == 0)
{
lblDigital.Text = string.Format( "0-{0} ", (18 - Out4PortCard - Out8PortCard) * 16);
lblOther.Text = string.Format( "0-{0} ", (18 - Out4PortCard - Out8PortCard) * 16);
}
if (iOther == 0)
{
lblOther.Text = string.Format( "0-{0} ", (18 - Out4PortCard - Out8PortCard - Dig8PortCard - Dig16PortCard) * 16);
return (18 - Out4PortCard - Out8PortCard - Dig8PortCard - Dig16PortCard) * 16;
}
else if (iDigital == 0)
{
lblDigital.Text = string.Format( "0-{0} ", (18 - Out4PortCard - Out8PortCard - Sim16PortCard) * 16);
return (18 - Out4PortCard - Out8PortCard - Sim16PortCard) * 16;
}