C language Operators - C++ Language Operators - In C#, an operator is a program element that is applied to one or more operands in an expression or statement. Operators that take one operand, such as the increment operator ( **++**) or **new**, are referred to as unary operators. Operators that take two operands, such as arithmetic operators ( **+** , **-** , ***** , **/** ), are referred to as binary operators. One operator, the conditional operator ( **? :** ), takes three operands and is the sole ternary operator in C#.

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

* | Multiplication |

/ | Division |

% | Remainder |

Expression | Description |
---|---|

x + y | Addition, string concatenation, delegate combination |

x - y | Subtraction, delegate removal |

Expression | Description |
---|---|

x << y | Shift left |

x >> y | Shift right |

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 |

Expression | Description |
---|---|

x == y | Equal |

x != y | Not equal |

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) |

We have a YouTube channel for live game streaming purposes, the channel name is "NightHawk". You can visit our gaming channel and support us, Thank you