All operators have a particular “precedence” depending on which group the operator falls in (operators of the same group have equal precedence). Meaning some operators will be applied before others. What follows is a list of groups (containing their respective operators) ordered by precedence (highest first):
a.b
- Member access.a?.b
- Null conditional member access.->
- Pointer dereferencing combined with member access.f(x)
- Function invocation.a
- Indexer.a?
- Null conditional indexer.x++
- Postfix increment.x--
- Postfix decrement.new
- Type instantiation.default(T)
- Returns the default initialized value of type T
.typeof
- Returns the Type
object of the operand.checked
- Enables numeric overflow checking.unchecked
- Disables numeric overflow checking.delegate
- Declares and returns a delegate instance.sizeof
- Returns the size in bytes of the type operand.+x
- Returns x
.-x
- Numeric negation.!x
- Logical negation.~x
- Bitwise complement/declares destructors.++x
- Prefix increment.--x
- Prefix decrement.(T)x
- Type casting.await
- Awaits a Task
.&x
- Returns the address (pointer) of x
.*x
- Pointer dereferencing.x * y
- Multiplication.x / y
- Division.x % y
- Modulus.x + y
- Addition.x – y
- Subtraction.x << y
- Shift bits left.x >> y
- Shift bits right.x < y
- Less than.x > y
- Greater than.x <= y
- Less than or equal to.x >= y
- Greater than or equal to.is
- Type compatibility.as
- Type conversion.x == y
- Equality.x != y
- Not equal.x & y
- Logical/bitwise AND.x ^ y
- Logical/bitwise XOR.x | y
- Logical/bitwise OR.x && y
- Short-circuiting logical AND.x || y
- Short-circuiting logical OR.x ?? y
- Returns x
if it is not null; otherwise, returns y
.x ? y : z
- Evaluates/returns y
if x
is true; otherwise, evaluates z
.