Operators in C#
Operators in C# allow you to perform various operations on variables and values, such as arithmetic, comparison, logical, and more. This guide introduces the different types of operators available in C# and provides examples to help you understand how to use them.
1. Types of Operators in C#​
C# supports various operators, which can be broadly categorized as follows:
- Arithmetic Operators
- Comparison Operators
- Logical Operators
- Assignment Operators
- Unary Operators
- Ternary Operator
2. Arithmetic Operators​
Arithmetic operators are used to perform basic mathematical operations.
Operator | Description | Example |
---|---|---|
+ | Addition | x + y |
- | Subtraction | x - y |
* | Multiplication | x * y |
/ | Division | x / y |
% | Modulus (Remainder) | x % y |