我有一个if ... else if语句如下:
If(x > y && order.invoice != 1)
{
DoSomething();
x = x + y;
}
else if(order.invoice == 1)
{
x = x + y;
}
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来重新考虑这一点.在if和else if中,我感觉不太好x = x + y.
if (order.invoice != 1 && x > y) {
DoSomething();
}
if (order.invoice == 1 || x > y) {
x = x + y;
}
Run Code Online (Sandbox Code Playgroud)