C# Operators
Operator is a symbol that is responsible for the operations. There can be variety of operators for example arithmetic, logical, bitwise and many more. There are following type of operators used to perform various operations in C# .
- Arithmetic Operators
- Logical Operators
- Bit wise Operators
- Relational Operators
- Assignment Operators
- Unary Operators
- Ternary Operators
- Misc Operators
- Binary Operators :
- +, -, *, /, %
- <, <=, >, >=, ==, !=
- &&, ||, !
- &, |, >>, <<, ~, ^
- =, +=, -=, *=, /=, %=
- Unary Operators
- ++, --
- Ternary Operators
- ?:
Category | Precedence | Associativity |
Unary | + - ! ~ ++ -- (type)* & sizeof | Right to Left |
Additive | + - | Left To Right |
Multiplicative | % / * | Left To Right |
Relational | <><= >= | Left To Right |
Shift | <<>> | Left To Right |
Equality | == != | Right To Left |
Logical AND | & | Left To Right |
Logical OR | | | Left To Right |
Logical XOR | ^ | Left To Right |
Conditional AND | || | Left To Right |
Conditional OR | && | Left To Right |
Null Coalescing | ?? | Left To Right |
Ternary | ?: | Right to Left |
Assignment | = *= /= %= += - = <<= >>= &= ^= |= => | Right to Left |