Lecture overview -- Keyboard shortcut: 'u'  Previous page: Structs -- Keyboard shortcut: 'p'  Next page: Commands and Control Structures -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 13 : 43
Object-oriented Programming in C#
Introduction to C#

This pages shows an overview of all operators in C#.

Most operators in C are also found in C#

LevelCategoryOperatorsAssociativity (binary/tertiary)
14Primaryx.y      f(x)      a[x]      x++      x--      new      typeof      checked      unchecked      default      delegateleft to right
13Unary+      -      !      ~      ++x      --x      (T)x      true      false      sizeofleft to right
12Multiplicative*      /      %left to right
11Additive+      -left to right
10Shift<<      >>left to right
9Relational and Type testing<      <=      >      >=      is      asleft to right
8Equality==      !=left to right
7Logical/bitwise and&left to right
6Logical/bitwise xor^left to right
5Logical/bitwise or|left to right
4Conditional and&&left to right
3Conditional or||left to right
2Null coalescing??left to right
1Conditional?:right to left
0Assignment or Lambda expression=      *=      /=      %=      +=      -=      <<=      >>=      &=      ^=      |=      =>right to left

The operator priority table of C#. Operators with high level numbers have high priorities. In a given expression, operators of high priority are evaluated before operators with lower priority. The associativity tells if operators at the same level are evaluated from left to right or from right to left.


It is possible to overload many of the C# operators

This allows for terse and convenient notation in many classes