resortdanax.blogg.se

Hand reference
Hand reference









The result of x | y is true if either x or y evaluates to true. The | operator computes the logical OR of its operands. Console.WriteLine(true ^ true) // output: FalseĬonsole.WriteLine(true ^ false) // output: TrueĬonsole.WriteLine(false ^ true) // output: TrueĬonsole.WriteLine(false ^ false) // output: Falseįor operands of the integral numeric types, the ^ operator computes the bitwise logical exclusive OR of its operands. That is, for the bool operands, the ^ operator computes the same result as the inequality operator !=. The result of x ^ y is true if x evaluates to true and y evaluates to false, or x evaluates to false and y evaluates to true. The ^ operator computes the logical exclusive OR, also known as the logical XOR, of its operands. The unary & operator is the address-of operator. The conditional logical AND operator & also computes the logical AND of its operands, but doesn't evaluate the right-hand operand if the left-hand operand evaluates to false.įor operands of the integral numeric types, the & operator computes the bitwise logical AND of its operands. In the following example, the right-hand operand of the & operator is a method call, which is performed regardless of the value of the left-hand operand: bool SecondOperand()Ĭonsole.WriteLine("Second operand is evaluated.") The & operator evaluates both operands even if the left-hand operand evaluates to false, so that the operation result is false regardless of the value of the right-hand operand. The result of x & y is true if both x and y evaluate to true. The & operator computes the logical AND of its operands. That is, it produces true, if the operand evaluates to false, and false, if the operand evaluates to true: bool passed = false Ĭonsole.WriteLine(!passed) // output: TrueĬonsole.WriteLine(!true) // output: Falseīeginning with C# 8.0, the unary postfix ! operator is the null-forgiving operator. The unary prefix ! operator computes logical negation of its operand. For more information, see Bitwise and shift operators. Those operators evaluate the right-hand operand only if it's necessary.įor operands of the integral numeric types, the &, |, and ^ operators perform bitwise logical operations.

  • Binary & (conditional logical AND) and || (conditional logical OR) operators.
  • Those operators always evaluate both operands.
  • Binary & (logical AND), | (logical OR), and ^ (logical exclusive OR) operators.
  • The following operators perform logical operations with bool operands:











    Hand reference