---
title: "How many types of operators are in C#, explain with example?"  
description: "How many types of operators are in C#, explain with example?"  
author: "Ethan Karla"  
published: 2021-08-25  
canonical: https://answers.mindstick.com/qa/93913/how-many-types-of-operators-are-in-c-sharp-explain-with-example  
category: "programming"  
tags: ["c#", "java", "pythons"]  
reading_time: 4 minutes  

---

# How many types of operators are in C#, explain with example?

How many types of [operators](https://www.mindstick.com/articles/13159/operating-press-brakes-an-ultimate-guide-for-brake-operators) are in C#, [explain](https://yourviews.mindstick.com/view/86025/content-created-for-humans-not-for-bots-explain-this-statement) with example?

## Answers

### Answer by Ravi Vishwakarma

**Operators** are the foundation of any programming language. Operators allow us to perform a variety of operations on operators. In C#, operators can be sorted based on their different functionality Operators are symbols that are used to perform operations on operands. Operands can be variables and/or constants. An operator is simply a symbol used to perform operations. C# language has the following types of operators to perform different types of operations.

1. Arithmetic Operators
2. Assignment Operators
3. Increment and Decrement Operators
4. Relational Operators
5. Logical Operators
6. Bitwise Operators
7. Ternary Operators

**Arithmetic Operators** In C#, Arithmetic operators are used to performing basic arithmetic operations like addition, subtraction, division, etc. **Relational Operators** In C#, relational operators are used to checking the relation between two operators, such that we can determine whether two operand values are equal or not, depending on our requirements. **Logical Operators** In C#, the logical operators AND, and NOT are used to perform logical operations between two operators based on our requirements, and the operators must contain only boolean values otherwise the logical operator will show an error. **Bitwise Operators** Bitwise operator is used to performing bit manipulation operations, in C#, Bitwise operator operates on bits and it is useful for performing a bit on bit operations like bitwise AND bitwise or bitwise exclusive or (^), etc. boolean and Level operations on integer data. **Assignment Operators** In C#, the assignment operator is used to assigning the new value to the operand. **Ternary Operator** The ternary operator works on three operators. It is a shorthand for the if-then-else statement. Ternary operator can be used as follows. **Example**

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ThreadDemo
{
    class OperatorDemo
    {
        public void ArithamaticOperator(params int[] val)
        {
            int sumResult = 0;
            int subResult = 0;
            foreach (int item in val)
            {
                sumResult += item;
                subResult -= item;
            }
            Console.WriteLine($'Sum : {sumResult} and Sub : {subResult}');
        }
        public void GretestInThreeNumber(int first,int second, int thierd)
        {
            if( ((first + second + thierd) / 3) == first)
            {
                Console.WriteLine('All values are same ...');
            }else if(first>second && first>thierd)
            {
                Console.WriteLine($'First is grater {first}');
            }else if (second > thierd)
            {
                Console.WriteLine($'Second is grater {second}');
            }
            else
            {
                Console.WriteLine($'Thierd is grater {thierd}');
            }
        }
        public void PrintData(int length)
        {
            for (int i = 1; i <= length; i++)
            {
                string space = i <= length-1 ? ',' : '\n';
                Console.Write(i + '' + space);
            }
        }
        public static void Main(string[] args)
        {
            OperatorDemo ope = new OperatorDemo();
            ope.ArithamaticOperator(5, 8, 4, 9, 6, 2, 3, 3, 40);
            ope.GretestInThreeNumber(10, 15, 10);
            ope.PrintData(20);
        }
    }
}
```

**Output** ![How many types of operators are in C#, explain with example?](https://answers.mindstick.com/questionanswer/be6ad848-cdc7-4793-b925-1aee19968fc4/images/84419ab4-f0e8-4ade-83b7-3bbbf23e6d55.png) **\** **\**


---

Original Source: https://answers.mindstick.com/qa/93913/how-many-types-of-operators-are-in-c-sharp-explain-with-example

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
