Operators and Expressions
Boolean Logical Operators
Unary
!
(logical negation) operator.Binary
&
(logicalAND
),|
(logicalOR
), and^
(logical exclusiveOR
) operators. Those operators always evaluate both operands.Binary
&&
(conditional logicalAND
) and||
(conditional logicalOR
) operators. Those operators evaluate the right-hand operand only if it's necessary.
For operands of the integral numeric types, the &
, |
, and ^
operators perform bitwise logical operations.
Logical negation operator !
Logical AND operator &
Logical OR operator |
x
y
x&y
x|y
true
true
true
true
true
false
false
true
true
null
null
true
false
true
false
true
false
false
false
false
false
null
false
null
null
true
null
true
null
false
false
null
null
null
null
null
Logical exclusive OR operator ^
Conditional logical AND operator &&
Conditional logical OR operator ||
Operator Precedence
!
> &
> ^
> |
> &&
> ||
null-coalescing operators (?? and ??=)
Last updated
Was this helpful?