C# operators (C# reference)

C# provides a number of predefined operators supported by the built-in types. For example, arithmetic operators perform arithmetic operations with operands of built-in numeric types and Boolean logical operators perform logical operations with the bool operands.

A user-defined type can overload certain operators to define the corresponding behavior for the operands of that type. For more information, see Operator overloading.

The following table lists the C# operators starting with the highest precedence to the lowest. The operators within each row share the same precedence level.

Operators Category or name
x.y, x?.y, x?[y], f(x), a[i], x++, x--, new, typeof, checked, unchecked, default, nameof, delegate, sizeof, stackalloc, x->y Primary
+x, -x, !x, ~x, ++x, --x, (T)x, await, &x, *x, true and false Unary
x * y, x / y, x % y Multiplicative
x + y, x – y Additive
x << y, x >> y Shift
x < y, x > y, x <= y, x >= y, is, as Relational and type-testing
x == y, x != y Equality
x & y Boolean logical AND or bitwise logical AND
x ^ y Boolean logical XOR or bitwise logical XOR
x | y Boolean logical OR or bitwise logical OR
x && y Conditional AND
x || y Conditional OR
x ?? y Null-coalescing operator
c ? t : f Conditional operator
x = y, x += y, x -= y, x *= y, x /= y, x %= y, x &= y, x |= y, x ^= y, x <<= y, x >>= y, => Assignment and lambda declaration

See also