The characters that contribute to the operation of the program are called operators. In programming languages, they have no meaning on their own.

Operators are special characters that are predefined and used to perform some mathematical or logical operations.

The constants or variables that the operators act on are called “operands”.

*a + b* this expression is operator +, and the operands are a and b.

*x++* this expression is operator ++ and the operand is x.

Do not forget;

• Operators have priority in parentheses.

Sample;

In a definition like (3+7)*4, it is necessary to do the addition operation first.

• If there are nested parentheses, first the innermost parentheses are performed, then the outer parentheses are done from the inside to the outside.

Each operator has a different task and operation and can be examined in 6 parts according to their functions.

### 1. Arithmetic Operators

( + ),( – ) , ( * ) ,( / ), ( + + ) ,( – – ) and ( % ) are arithmetic operators.

The ( / ), ( * ), ( + ) and ( – ) operators perform mathematical operations.

The ( % ) operator is used to find the remainder after the division, that is, to get the “mod”.

( + + ) and ( – – ) increase or decrease the number to which the operation is applied by 1.

Operators ( * ), ( / ), ( % ) have equal precedence if they are on the same line. The ( + ) and ( –) operators have equal precedence if they are on the same line, but the ( * ), ( / ), ( % ) operators have precedence over the ( + ) and ( – ) operators.

### 2. Comparison operators

There are 6 comparison operators in C#.

These;

- ( < ) is less
- ( > ) is large
- ( <= ) is less than or equal to
- ( >= ) is greater than or equal to
- ( == ) equals
- ( != ) is not equal

The ( < ), ( > ), ( <= ), ( >=) operators take precedence over the ( == ) and ( != ) operators. But it has equal priority when they are on the same line.

### 3. Bitwise operators

- There are 6 comparison operators in C#. These; ( & ) bitwise, ( ~ ) bitwise, ( | ) bitwise or, ( ^ ) bitwise special or.
- Operators that use their bits instead of numbers themselves.
- ( & ) “and” operation keeps 1 in its respective digit if both of the reciprocal digits are 1, and 0 in other cases.
- The ( ~ ) “not” operator reverses and keeps each digit of its operand.
- ( | ) If any of the reciprocal digits of the “or” operation is 1, it amounts to 1 in the relevant digit, and 0 in other cases.
- ( ^ ) “special or” operation keeps 1 in its respective digit if the reciprocal digits are different, and 0 in other cases.
- When these operators are on the same line, the precedence between them ( & ) is “bitwise and”,
- ( ^ ) is “bitwise special or”, ( | ) is “bitwise or”.

### 4. Logical operators

- There are 3 logical operators in C#. These; ( && ) and are operators ( || ) or , not ( ! ).
- The ( || ) “or” operator returns true if one of the two values is true, false if both are false, and is the logical operator with the least priority.
- The ( && ) “and” operator returns true if both values are true, and false if at least one of them is false.
- ( && ) “and”, ( || ) “or” operators have lower priority than arithmetic, comparison and bitwise operators, but their precedence is &&(ve), ||(or).
- The ( ! ) “not” operator takes precedence over the arithmetic operators ( ++ ) increment and ( — ) decrement operators.

### 5. Assignment and operative assignment operators

- The ( = ) “assign” operator is used to assign any value to a variable.
- Operators such as ( *= 9), ( /= ), ( += ), (-= ), ( &= ), ( ^= ), ( |= ) are called operative assignment operators. Its usage is as follows;

=> a+=b instead of a=a+b

=> a/=b instead of a=a/b

=> a^=b instead of a=a^b

- If assignment and operand assignment operators are on the same line, their priority order is equal from left to right. However, in general, these operators are in the last place in terms of priority order.

### 6. Special purpose operators

- The ?: operator: is the only operator in C# that takes three operands. Use of; condition ? true value : false value
- () type conversion operator: It is an operator used to change the type.

(type to change) variable_or_constant - [] operator: It is used to specify the index of the element in arrays.
- + and – operator: Makes a variable be positive or negative. The + operator is also used to concatenate two strings. Its usage is as follows;
string x = “Test”;

string y = “Try”;

string z = x + y;When expressed as “TestTest”, variable c is assigned.

- typeof operator: It keeps the CTS (Common Type System) equivalent of any variable type as type(type).
- sizeof operator: Returns how much memory the base types and structures take up. The “sizeof” operator cannot be used for classes, but can be used for structures to be defined.
- new operator: Operators used to create a new object.

If special-purpose operators are on the same line, their order of precedence is equal, but these operators take first place in terms of priority when compared to other operators.