IF语句中的C#OR规范


C# OR specification in IF statement

本问题已经有最佳答案,请猛点这里访问。

如果有如果空调类:

1
2
3
4
if(x == 0 || y == 4)
{
// ...
}

然后,如果是真的话x == 0C #支票如果y == 4虽然我们已经知道整个表达的是真的吗?


The conditional-OR operator (||) performs a logical-OR of its bool operands. If the first operand evaluates to true, the second operand isn't evaluated.

http://docs.microsoft.com /美国/ Dotnet CSharp语言参考/ / / /条件或Laplacian算子


看看MSDN。那么答案是NO,它不检查

The conditional-OR operator (||) performs a logical-OR of its bool
operands. If the first operand evaluates to true, the second operand
isn't evaluated. If the first operand evaluates to false, the second
operator determines whether the OR expression as a whole evaluates to
true or false.