Operators are the foundation of any programming language, the program is incomplete without the operators as we use them in all of our programs.

Operators are the symbol that performs a specific mathematical or logical operation on operands.
Example: Addition : `2 + 3`, where 2 and 3 are the operands and + is the operator.

Following are the types of Operators in C#.

• Arithmetic Operators
• Assignment Operators
• Relational Operators
• Logical Operators
• Unary Operators
• Bitwise Operators
• Ternary or Conditional Operator
• Miscellaneous Operators

## C# Arithmetic Operators

Arithmetic Operators are used to perform mathematical operations on operands such as addition, subtraction, multiplication, division etc.

## C# Assignment Operators

These operators are used in a program to assign a value of the right-hand side to the left-hand side as shown below.

You can combine write in short version such as instead of writing, `int a = a+5`, you can write it as `a += 5`.

Following are the list of assignment operators used in C#.

## C# Relational Operators

These operators are used in a program to check the relationship between two operands and accordingly, it returns boolean values, true or false. These are used with loops and Decision-Making Statements during condition checking.

List of relational operators in C#:

## C# Logical Operators

These operators are used to compute the logical operation in a program such as `&&``||` and `!`. They are used to evaluate the condition.

The following are the C# Logical Operators. Assume X holds the value 1 and Y holds 0

## C# Unary Operators

These operators are the Increment and Decrement Operators. They operate on a single operand. They are `++` and `--` operators. ++ is used to increase the value by 1 and — is used to decrease the value by 1.

• Post-Increment or Post-Decrement:
First, the value is used for operation and then incremented or decremented. Represented as a++ or a–.
• Pre-Increment Pre-Decrement:
Here First the value is incremented or decremented then used for the operation. Represented as ++a or –a.

## C# Bitwise Operators

Bitwise operators are used to perform a bit-level operation on operands. They are used in testing, setting, or shifting the actual bits in a program.

You can see the truth table below.

Below are the list of Bitwise operators:

## C# Ternary or Conditional Operator (`?:`)

It is a short-hand version of the if-else statement that operates on three operands. The ternary operator (or Conditional operator) returns a true or false after checking the condition.

Syntax of ternary operator:

Explanation:

• condition: It checks the condition for a true or false value.
• expression1: If the condition is true expression1 is evaluated.
• expression2: If the condition is false expression2 is evaluated.

Output:

## Miscellaneous Operators

Apart from the above operators, there are various other operators used in C# programming and they are:

## Operator Precedence in C#

In a program, there may be an expression that uses more than one operator, in such case operator precedence determines which is to be evaluated first and next.

Let us take an example:

The output of the above expression is 60 because the precedence of multiplication is higher than the addition. So first (5 * 10) is evaluated and then 10 is added to the result.

The following shows the precedence and associativity of C# operators:

Associativity refers to the direction of the operators to be evaluated first and next. It may be right to left or left to right.

### Find the output ab, cd, ef, g for the input a,b,c,d,e,f,g in Javascript and Python

In this tutorial, we will write a program to find a pairs of elements from an array such that for the input [a,b,c,d,e,f,g] we will …

### String Pattern Programs in C

In this tutorial, we will write various C pattern programs for String. Before that, you may go through the following topics in C. for loop …

### Java Program to Find pair of Integers in Array whose sum is given Number

In this tutorial, we will write a program to find a pair of elements from an array whose sum equals a given number in java …

### Program to Print Diamond Alphabet Patterns in C

In this tutorial, we will learn to write a C program to print Diamond patterns using alphabets/characters. However, in this tutorial, we will create a …

### Half Diamond Pattern in C using Alphabets

In this tutorial, we will learn and code the half diamond alphabet patterns in C programming language. However, in this tutorial, we will create a …

### Half Pyramid of Alphabets in C

In this tutorial, we will learn and code alphabet patterns in C programming language specifically the Half pyramid of alphabets in C programming. However, in …