C# - Operator &, | and ^ can also operate bool operands

来源:互联网 发布:java面试试题及答案 编辑:程序博客网 时间:2024/06/04 01:22

Yes, binary operators&,| and^ are also predefined for the bool type.


& computes the logical AND of its operands; that is, the result is true if and only if both its operands are trueThe & operator evaluates both operators regardless of the first one's value.

| computes the logical OR of its operands; that is, the result is false if and only if both its operands are false.

^ computes the logical exclusive-or of its operands; that is, the result is true if and only if exactly one of its operands is true.

773 0