C Sharp Operators

by Dinesh 2012-07-22 20:30:58

C# Operators



Results are computed by building expressions. These expressions are built by combining variables and operators together into statements. The following table describes the allowable operators, their precedence, and associativity.

Operators with their precedence and Associativity
Category (by precedence) Operator(s) Associativity
Primary x.y f(x) a[x] x++ x-- new typeof default checked unchecked delegate left
Unary + - ! ~ ++x --x (T)x right
Multiplicative * / % left
Additive + - left
Shift << >> left
Relational < > <= >= is as left
Equality == != right
Logical AND & left
Logical XOR ^ left
Logical OR | left
Conditional AND && left
Conditional OR || left
Null Coalescing ?? left
Ternary ?: right
Assignment = *= /= %= += -= <<= >>= &= ^= |= => right

Left associativity means that operations are evaluated from left to right. Right associativity mean all operations occur from right to left, such as assignment operators where everything to the right is evaluated before the result is placed into the variable on the left.
643
like
0
dislike
0
mail
flag

You must LOGIN to add comments