O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.1. Operators and their precedence in C#

Table 10.1. C# operators in decreasing order of precedence
Higher precedence
Operator categoryOperators
Primaryx.y f(x) a[x] x++ x-- new typeof checked unchecked
Unary+ – ! ~ ++x --x (T)x
Multiplicative* / %
Additive+ -
Shift<< >>
Relational and type testing< > <= >= is as
Equality== !=
Logical AND&
Logical XOR^
Logical OR|
Conditional AND&&
Conditional OR||
Conditional (ternary)?:
Assignment= *= /= %= += -= <<= >>= &= ^= |=

All operators in the same category have the same precedence. To decide which operator in a particular group takes precedence, follow these associative rules:

  • except for the assignment operators, all other binary operators are left associative – for example, a+b-c is the same as (a+b)-c;

  • the assignment ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required