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 :

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 :

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

* Multiplication
/ Division
% Remainder

Additive Operators :

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

Shift Operators :

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

Relational and Type Operators :

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 :

x == y Equal
x != y Not equal

Logical, Conditional, and Null Operators :

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 :

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

Computer Science Engineering

Special Notes

It's a special area where you can find special questions and answers for CSE students or IT professionals. Also, In this section, we try to explain a topic in a very deep way.

CSE Notes