In C#, operators are nothing but mathematical or logical operators that tell the compiler to perform a specific operation. For instance, a multiplication (*) operator tells the compiler to multiply; on the other hand, the logical and (&&) operator checks both the operands. We can divide C# operators into broader types, as shown in the following table:
Type |
Operator |
Description |
Arithmetic operators |
+ |
Adds two operands, for example, var result = num1 +num2; |
- |
Subtracts second operand from first operand, for example, var result = num1 - num2; |
|
* |
Multiplies both operands, for example, var result = num1 * num2; |
|
/ |
Divides the numerator by the denominator, for example, var result = num1 / num2; |
|