Boolean logical operators
The predefined boolean logical operators are: bool operator &(bool x, bool y); bool operator |(bool x, bool y); bool operator ^(bool x, bool y); The result of x & y is true if both x and y are true. Otherwise, the result is false. The result of x | y is true if either x or y is true. Otherwise, the result is false. The result of x ^ y is true if x is true and y is false, or x is false and y is true. Otherwise, the result is false. When the operands are of type bool, the ^ operator computes the same result as the!= operator. Nullable boolean logical operators The nullable boolean type bool? can represent three values, true, false, and null, and is conceptually similar to the three-valued type used for boolean expressions in SQL. To ensure that the results produced by the & and | operators for bool? operands are consistent with SQL’s three-valued logic, the following predefined operators are provided: bool? operator &(bool? x, bool? y); bool? operator |(bool? x, bool? y); The following table lists the results produced by these operators for all combinations of the values true, false, and null.
|