C# Operators :

Operators :

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

Primary Operators :

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

Unary Operators :

ExpressionDescription
+x Identity
-x Negation
!x Logical negation
~x Bitwise negation
++x Pre-increment
--x Pre-decrement
(T)x Explicitly convert x to type T

Multiplicative Operators :

ExpressionDescription
* Multiplication
/ Division
% Remainder

Additive Operators :

ExpressionDescription
x + y Addition, string concatenation, delegate combination
x - y Subtraction, delegate removal

Shift Operators :

ExpressionDescription
x << y Shift left
x >> y Shift right

Relational and Type Operators :

ExpressionDescription
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

Equality Operators :

ExpressionDescription
x == y Equal
x != y Not equal

Logical, Conditional, and Null Operators :

CategoryExpressionDescription
Logical ANDx & y Integer bitwise AND, Boolean logical AND
Logical XORx ^ y Integer bitwise XOR, boolean logical XOR
Logical ORx | y Integer bitwise OR, boolean logical OR
Conditional ANDx && y Evaluates y only if x is true
Conditional ORx || y Evaluates y only if x is false
Null coalescingx ?? y Evaluates to y if x is null, to x otherwise
Conditionalx ? y : z Evaluates to y if x is true, z if x is false

Assignment and Anonymous Operators :

ExpressionDescription
= Assignment
x op= y Compound assignment. Supports these operators: +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=
(T x) => y Anonymous function (lambda expression)

Next Update

Loading...

We have two YouTube channels their name is CodeX or NightHawk. CodeX is for programming related videos and NightHawk is for online game streaming so please supporting us and Subscribe to our channels