Assignment and Logical Operators
Learn about the assignment operator, logical operators, and conditional logical operators.
Operators like =
, +
, -
, *
, and /
can be combined with an assignment to shorthand expressions. Logical operators like &
, |
, and ^
act on Boolean values to perform logic operations. Understanding these operators can help us write more efficient C# code.
Assignment operators
We have been using the most common assignment operator, =
. To make our code more concise, we can combine the assignment operator with other operators, like arithmetic operators, as shown in the following code:
Get hands-on with 1400+ tech skills courses.