C# Operators
Same as like other programming languages, C# also uses the operators to perform different types of operations. There are different kinds of operators that can be used in C#.
Types of operators:
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Unary Operators
- Ternary Operators
- Misc Operators
Arithmetic Operators
Name |
Operator |
Addition |
+ |
Subtraction |
- |
Multiplication |
* |
Division |
/ |
Modulus |
% |
Increment |
++ |
Decrement |
-- |
Assignment Operators
Name |
Example |
= |
x = 10 |
+= |
x += 10 |
-= |
x -= 10 |
*= |
x *= 10 |
/= |
x /= 10 |
%= |
x %= 10 |
&= |
x &= 10 |
|= |
x |= 10 |
^= |
x ^= 10 |
>>= |
x >>= 10 |
<<= |
x <<= 10 |
Comparison Operators
Name |
Operator |
Equal to |
== |
Not equal |
!= |
Greater than |
> |
Less than |
< |
Greater than or equal to |
>= |
Less than or equal to |
<= |
Logical Operators
Name |
Operator |
Logical and |
&& |
Logical or |
|| |
Logical not |
! |