Logical, conditional, and null operators

C# allows you to combine the aforementioned operators with OR (||), AND (&&), or XOR (^). These are applied to both operands in an expression.

The following table lists the logical, conditional, and null operators:

Expression Description and example
Logical OR (|) This operator computes both operands and returns false if both are false.
Logical AND (&) This operator can be used in two forms: Unary address operator or Binary logical operator. When used as a Unary address operator, it returns the address of the operand. If used as a Binary, it evaluates both operands and returns true if both operands are true; otherwise, it will return false.
Conditional AND (&&) This conditional operator is ...

Get Programming in C#: Exam 70-483 (MCSD) Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.