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# .

  1. Arithmetic Operators
  2. Logical Operators
  3. Bit wise Operators
  4. Relational Operators
  5. Assignment Operators
  6. Unary Operators
  7. Ternary Operators
  8. Misc Operators
Types Of Operators according to number of operands :
  1. Binary Operators :
  2. +, -, *, /, %
  3. <, <=, >, >=, ==, !=
  4. &&, ||, !
  5. &, |, >>, <<, ~, ^
  6. =, +=, -=, *=, /=, %=
  7. Unary Operators
  8. ++, --
  9. Ternary Operators
  10. ?:
Precedence of Operators Precedence of the operators specifies which operation to be evaluated first. Expression      is evaluated according to the precedence of the operator. If the precedence of two operators is same then the expression will be evaluated according to Operator’s Associativity.
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