C# is just like other programming languages like C, C++, etc. C# is also providing some common operators for specifying the compiler to perform specific manipulations or changes like mathematical operations, logical operations, etc., on the data.
List of C# Operators and their description
C# Operators are basically of three types depending on the number of operands. The operand is nothing but the data on which the operator is working on.
|Operators in C#||Description|
|Arithmetic Operators||The C# Arithmetic Operators like +, -, *, /, % are useful to tell the compiler to perform specific mathematical calculations on the operands like addition, subtraction, multiplication, division, modulus respectively.|
|Relational Operators||Relational Operators like = =, >, >=, <, <=, != generally checks the relation by comparing two variables and gives True or False (Boolean) result. These C# Relational operators are useful in controlling the program flow.|
|Logical Operators||Logical Operators like &&, ||, ! allows us to check whether multiple operations are true. Usually, these C# Logical Operators are useful in combination with the relational operators.|
|Bitwise Operators||Bitwise operators &, |, ^, ~ perform operations on bits. These operators will take the decimal input and will convert decimal to binary, performs bitwise operations, and finally, the binary result is converted to decimal and gives it as output.|
|Shift Operators||Shift operators like >>, << performs the right shift or left shift on the left operand by moving the left or right side by the number of bits(specified in the right operand).|
|Unary Operators||++, – – are unary operators as these operators work on a single operand. These are also called C# increment and decrement operators.|
|Assignment Operators||Assignment Operators like =, + =, – =, / =, % = are used to assign values to the variables. Most commonly used in the real time environment is ‘=’ operator.|
|Ternary Operator||Ternary Operator ?: is also called a conditional operator that works on three operands. |
If the statement is true ? then x : else y
|Null Coalescing Operator||Variable x= variable y ?? value.|
Variable x will be assigned value if variable y is null; otherwise, the value in the variable y assigned.