Results are computed by building expressions. These expressions are built by combining variables and operators together into statements. The following table describes the allowable operators, their precedence, and associativity.

Operators with their precedence and Associativity

Category (by precedence) Operator(s) Associativity

Primary x.y f(x) a[x] x++ x-- new typeof default checked unchecked delegate left

Unary + - ! ~ ++x --x (T)x right

Multiplicative * / % left

Additive + - left

Shift << >> left

Relational < > <= >= is as left

Equality == != right

Logical AND & left

Logical XOR ^ left

Logical OR | left

Conditional AND && left

Conditional OR || left

Null Coalescing ?? left

Ternary ?: right

Assignment = *= /= %= += -= <<= >>= &= ^= |= => right

Primary x.y f(x) a[x] x++ x-- new typeof default checked unchecked delegate left

Unary + - ! ~ ++x --x (T)x right

Multiplicative * / % left

Additive + - left

Shift << >> left

Relational < > <= >= is as left

Equality == != right

Logical AND & left

Logical XOR ^ left

Logical OR | left

Conditional AND && left

Conditional OR || left

Null Coalescing ?? left

Ternary ?: right

Assignment = *= /= %= += -= <<= >>= &= ^= |= => right

Left associativity means that operations are evaluated from left to right. Right associativity mean all operations occur from right to left, such as assignment operators where everything to the right is evaluated before the result is placed into the variable on the left.

You must LOGIN to add comments