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 it is working on.
|Arithmetic||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||= =, >, >=, <, <=, != 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||&&, ||, ! allows us to check whether multiple operations are true. Usually, these C# Logical Operators are useful in combination with the relational.|
|Bitwise||&, |, ^, ~ perform operations on bits. These 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||>>, << 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||++, – – are unary as these work on a single operand. These are also called C# increment and decrement operators.|
|Assignment||=, + =, – =, / =, % = are used to assign values to the variables. Most commonly used in the real time environment is ‘=’ operator.|
|Ternary||?: is also called a conditional operator that works on three operands. |
If the statement is true ? then x : else y
|Null Coalescing||Variable x= variable y ?? value.|
Variable x will be assigned value if variable y is null; otherwise, the value in the variable y assigned.