If statements and && or ||

后端 未结 12 1322
臣服心动
臣服心动 2020-12-22 02:54

OK so I\'m a beginner with C# and I am having trouble understanding the if statement below.

For this example INumber is declared as 8, dPrice is 0 and dTAX is 10.

12条回答
  •  爱一瞬间的悲伤
    2020-12-22 03:43

    The || OR operator means only one OR the other has to be true. In this case, iNumber != 9, so that portion of the code is true and it enters the statement. I think you'll want to use the && AND operator to indicate that it can't be 8 AND it can't be 9.

提交回复
热议问题