Expression | Description |
x.y | Member access |
x?.y | Conditional member access |
f(x) | Method and delegate invocation |
a[x] | Member access |
x.y | Array and indexer access |
a?[x] | Conditional array and indexer access |
x++ | Post-increment |
x-- | Post-decrement |
new T(...) | Object and delegate creation |
new T(...){...} | Object creation with initializer. |
new {...} | Anonymous object initializer. |
new T[...] | Array creation. |
typeof(T) | Obtain System.Type object for T |
checked(x) | Evaluate expression in checked context |
unchecked(x) | Evaluate expression in unchecked context |
default (T) | Obtain default value of type T |
delegate {} | Anonymous function (anonymous method) |
Expression | Description |
+x | Identity |
-x | Negation |
!x | Logical negation |
~x | Bitwise negation |
++x | Pre-increment |
--x | Pre-decrement |
(T)x | Explicitly convert x to type T |
Expression | Description |
x + y | Addition, string concatenation, delegate combination |
x - y | Subtraction, delegate removal |
Expression | Description |
x < y | Less than |
x > y | Greater than |
x <= y | Less than or equal |
x >= y | Greater than or equal |
x is T | Return true if x is a T, false otherwise |
x as T | Return x typed as T, or null if x is not a T |
Category | Expression | Description |
Logical AND | x & y | Integer bitwise AND, Boolean logical AND |
Logical XOR | x ^ y | Integer bitwise XOR, boolean logical XOR |
Logical OR | x | y | Integer bitwise OR, boolean logical OR |
Conditional AND | x && y | Evaluates y only if x is true |
Conditional OR | x || y | Evaluates y only if x is false |
Null coalescing | x ?? y | Evaluates to y if x is null, to x otherwise |
Conditional | x ? y : z | Evaluates to y if x is true, z if x is false |
Expression | Description |
= | Assignment |
x op= y | Compound assignment. Supports these operators: +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>= |
(T x) => y | Anonymous function (lambda expression) |