- HTML Comments Tutorial | Convert Comments into HTML Codes
- Data Structure and Algorithms Tutorial | Ultimate Guide to Learn
- Gradle Tutorial | For Beginners [ STEP-IN ]
- Encapsulation In Java | Complete Tutorial With Examples
- What is Release Management? | A Comprehensive Tutorial for Beginners
- OOPs Concepts in Java | Learn from Basics with Examples
- The Top Basic Tools of Quality Tutorial | The Ultimate Guide
- Set Environment for C# – Learn How to Setup through this Tutorial
- C# Vs Java Tutorial | Overview and Key Difference
- List of IDEs to run C# Programs | Tutorial for Learning Path
- C Sharp Variables and Constants | The Ultimate Guide
- Unsafe Code in C-Sharp Tutorial | Everything You Need to Know
- Type Conversion Method in C# | A Complete Tutorial
- What Is Synchronization in c# Tutorial | The BEST Step-By-Step Guide
- Understanding Structures in C# | Learn in 1 Day FREE Tutorial
- Strings – C# Tutorial | A Definitive Programming Guide
- Static Keyword in C# Tutorial | Learn with Examples
- Stack Collection in C# Tutorial | A Definitive Guide for Beginners
- C# Sorted List Tutorial with Examples | Learn in 1 Day FREE
- C# Serialization Tutorial | Ultimate Guide to Learn [BEST & NEW]
- Regular Expression in C# Tutorial | Everything You Need to Know
- What is Reflection in C#? | Learn Now Tutorial
- Queue Collection in C# Tutorial | A Definitive Guide
- Properties in C# | The complete Tutorial
- C# Preprocessor Directives Tutorial | Learn in 1 Day FREE
- Polymorphism C# Tutorial | The Ultimate Guide
- C# Operators Tutorial | Learn Arithmetic, Comparison, Logical Concepts
- Namespaces – The complete C# Tutorial
- Multithreading in C# Tutorial | Learn With Examples and Advantages
- Methods – C# Tutorial | A Complete Programming Guide
- Linked List Implementation in C# Tutorial | Ultimate Guide to Learn [UPDATED]
- Introduction to C# Tutorial | Guide for Beginners
- What is Interface in C# | A Defined Free Tutorial
- C# Inheritance Tutorial | A Complete Free Tutorial
- Indexers in C# Tutorial | A Complete Programming Guide
- HashSet Collection in C# Tutorial | Complete Guide Tutorial For Free
- Generics in C# Tutorial | Learn Generic Classes and Methods
- Creating Your First C# Program Tutorial | Learn in 1 Day
- Basics of File Handling in C# Tutorial | The Ultimate Guide
- C# Exception Handling Tutorial | Learn with Best Practices
- Events – C# Tutorial | A Complete Programming Guide
- C# Enumerations Type Tutorial | Learn Everything about Enum
- Dictionary Collection in C# | Ultimate Guide to Learn [NEW & UPDATED]
- Delegates – C# Programming Guide | The Ultimate Guide for Beginners
- Understanding Decision Making Statements in C# | Learn Now Tutorial
- Classes and Objects – C# Fundamentals Tutorial
- C# BitArray Collection Tutorial | Learn in 1 Day FREE
- Attributes in C# Tutorial | Learn to work with attributes in C#
- C# Array Tutorial | Create, Declare, Initialize
- ArrayList Collection on in C# | A Complete tutorial For Beginners
- Anonymous Methods and Lambdas – C# Tutorial | A Complete Guide
- Abstraction in C# Tutorial – Learn the Abstract class and Interface
- Game Development using Unity 3D Tutorial | Ultimate Guide to Learn [UPDATED]
- C++ Reference Tutorial | A Comprehensive Guide for Beginners
- PHP vs Python | Which Is Better For Web Development
- C++ Constructors Tutorial: Types and Copy Constructors
- JavaScript Arrays Tutorial | Complete Beginner’s Guide
- What Is Maven | Maven Tutorial For Beginners
- Spring Tutorial | Perfect Guide for Beginners
- React Hooks Tutorial for Beginners | Ultimate Guide to Learn
- Python for Data Science Tutorial | Quickstart : A Complete Guide
- What is Golang? : A tutorial for beginners | Get started
- Hibernate Validator Tutorial | Learn in 1 Day FREE
- Postman Tutorial for Beginners: API Testing using Postman | A Complete Guide
- Akka Tutorial
- J2EE | Web Development Tutorial for Beginners
- Scala Exception Handling Tutorial | Learn in 1 Day [ STEP-IN ]
- Web development Tutorial
- Visual Studio Tutorial
- PyGame Tutorial
- Python Anaconda Tutorial
- Python Scikit-Learn Cheat Sheet Tutorial
- Mean Stack Tutorial
- Python Requests Tutorial
- Advanced Java Tutorial
- Spring Boot Microservices Tutorial
- Java Servlets Tutorial
- How to Install Pycharm
- Pycharm Tutorial
- Python Version Tutorial
- Python strings
- How to Download Python
- C Data Types Tutorial
- arrays in python
- Python While Loop Tutorial
- JAVA Tutorial
- Loops In C Tutorial
- Java File I/O Tutorial
- Variables in Python Tutorial
- Python Tutorial
- Python Pandas Cheat Sheet Tutorial
- Data Structures Cheat Sheet with Python Tutorial
- Python Tuples Tutorial
- Python If Else Statements Tutorial
- Python Functions Tutorial
- HTML Comments Tutorial | Convert Comments into HTML Codes
- Data Structure and Algorithms Tutorial | Ultimate Guide to Learn
- Gradle Tutorial | For Beginners [ STEP-IN ]
- Encapsulation In Java | Complete Tutorial With Examples
- What is Release Management? | A Comprehensive Tutorial for Beginners
- OOPs Concepts in Java | Learn from Basics with Examples
- The Top Basic Tools of Quality Tutorial | The Ultimate Guide
- Set Environment for C# – Learn How to Setup through this Tutorial
- C# Vs Java Tutorial | Overview and Key Difference
- List of IDEs to run C# Programs | Tutorial for Learning Path
- C Sharp Variables and Constants | The Ultimate Guide
- Unsafe Code in C-Sharp Tutorial | Everything You Need to Know
- Type Conversion Method in C# | A Complete Tutorial
- What Is Synchronization in c# Tutorial | The BEST Step-By-Step Guide
- Understanding Structures in C# | Learn in 1 Day FREE Tutorial
- Strings – C# Tutorial | A Definitive Programming Guide
- Static Keyword in C# Tutorial | Learn with Examples
- Stack Collection in C# Tutorial | A Definitive Guide for Beginners
- C# Sorted List Tutorial with Examples | Learn in 1 Day FREE
- C# Serialization Tutorial | Ultimate Guide to Learn [BEST & NEW]
- Regular Expression in C# Tutorial | Everything You Need to Know
- What is Reflection in C#? | Learn Now Tutorial
- Queue Collection in C# Tutorial | A Definitive Guide
- Properties in C# | The complete Tutorial
- C# Preprocessor Directives Tutorial | Learn in 1 Day FREE
- Polymorphism C# Tutorial | The Ultimate Guide
- C# Operators Tutorial | Learn Arithmetic, Comparison, Logical Concepts
- Namespaces – The complete C# Tutorial
- Multithreading in C# Tutorial | Learn With Examples and Advantages
- Methods – C# Tutorial | A Complete Programming Guide
- Linked List Implementation in C# Tutorial | Ultimate Guide to Learn [UPDATED]
- Introduction to C# Tutorial | Guide for Beginners
- What is Interface in C# | A Defined Free Tutorial
- C# Inheritance Tutorial | A Complete Free Tutorial
- Indexers in C# Tutorial | A Complete Programming Guide
- HashSet Collection in C# Tutorial | Complete Guide Tutorial For Free
- Generics in C# Tutorial | Learn Generic Classes and Methods
- Creating Your First C# Program Tutorial | Learn in 1 Day
- Basics of File Handling in C# Tutorial | The Ultimate Guide
- C# Exception Handling Tutorial | Learn with Best Practices
- Events – C# Tutorial | A Complete Programming Guide
- C# Enumerations Type Tutorial | Learn Everything about Enum
- Dictionary Collection in C# | Ultimate Guide to Learn [NEW & UPDATED]
- Delegates – C# Programming Guide | The Ultimate Guide for Beginners
- Understanding Decision Making Statements in C# | Learn Now Tutorial
- Classes and Objects – C# Fundamentals Tutorial
- C# BitArray Collection Tutorial | Learn in 1 Day FREE
- Attributes in C# Tutorial | Learn to work with attributes in C#
- C# Array Tutorial | Create, Declare, Initialize
- ArrayList Collection on in C# | A Complete tutorial For Beginners
- Anonymous Methods and Lambdas – C# Tutorial | A Complete Guide
- Abstraction in C# Tutorial – Learn the Abstract class and Interface
- Game Development using Unity 3D Tutorial | Ultimate Guide to Learn [UPDATED]
- C++ Reference Tutorial | A Comprehensive Guide for Beginners
- PHP vs Python | Which Is Better For Web Development
- C++ Constructors Tutorial: Types and Copy Constructors
- JavaScript Arrays Tutorial | Complete Beginner’s Guide
- What Is Maven | Maven Tutorial For Beginners
- Spring Tutorial | Perfect Guide for Beginners
- React Hooks Tutorial for Beginners | Ultimate Guide to Learn
- Python for Data Science Tutorial | Quickstart : A Complete Guide
- What is Golang? : A tutorial for beginners | Get started
- Hibernate Validator Tutorial | Learn in 1 Day FREE
- Postman Tutorial for Beginners: API Testing using Postman | A Complete Guide
- Akka Tutorial
- J2EE | Web Development Tutorial for Beginners
- Scala Exception Handling Tutorial | Learn in 1 Day [ STEP-IN ]
- Web development Tutorial
- Visual Studio Tutorial
- PyGame Tutorial
- Python Anaconda Tutorial
- Python Scikit-Learn Cheat Sheet Tutorial
- Mean Stack Tutorial
- Python Requests Tutorial
- Advanced Java Tutorial
- Spring Boot Microservices Tutorial
- Java Servlets Tutorial
- How to Install Pycharm
- Pycharm Tutorial
- Python Version Tutorial
- Python strings
- How to Download Python
- C Data Types Tutorial
- arrays in python
- Python While Loop Tutorial
- JAVA Tutorial
- Loops In C Tutorial
- Java File I/O Tutorial
- Variables in Python Tutorial
- Python Tutorial
- Python Pandas Cheat Sheet Tutorial
- Data Structures Cheat Sheet with Python Tutorial
- Python Tuples Tutorial
- Python If Else Statements Tutorial
- Python Functions Tutorial

C# Operators Tutorial | Learn Arithmetic, Comparison, Logical Concepts
Last updated on 16th Aug 2022, Blog, Software Engineering, Tutorials
C# Operators Introduction :-
Administrators in C# square measure Special Symbols to Denote the Operation That the Program must Perform. This Tutorial Explains C# Operators thoroughly With Examples:
In our past tutorial exercise, we tend to observed with regards to Conditional Statements in C#. We tend to in addition find out a way to utilize if, if-else and if-else if explanations to characterize varied conditions.A contingent assertion, for instance, “if” is otherwise known as a dynamic assertion as they provide the consumer a element to characterize a end in read of a selection characterized by directors.The directors provide a technique for characterizing decisions visible of Logic, Arithmetic Operations, Comparison, so forth An administrator is a picture that advises the compiler to perform specific numerical or legitimate controls. C# has made arrangement of underlying directors and provides the related kind of kind of

- Math Operators
- Social Operators
- Coherent Operators
- Bitwise Operators
- Task Operators
- Misc Operators
Math Operators :-
Following table shows each one of the mathematics directors upheld by C#. Expect variable A holds ten and variable B holds twenty then, at that time, −
Operator | Description Example |
---|---|
+ | Adds 2 operands A + B = thirty |
– | Subtracts second quantity from the first A – B = -10 |
* | Multiplies each operands A * B = two hundred |
/ | Divides dividend by de-numerator B / A = a pair of |
% | Modulus Operator associated remainder of once an number division B you are a = zero |
++ | Increment operator will increase number worth by one A++ = eleven |
— | Decrement operator decreases number worth by one A– = nine |
Social Operators :-
Following table shows each one of the social directors upheld by C#. settle for variable A holds ten and variable B holds twenty, then, at that time, −
Operator | Description Example |
---|---|
== | Checks if the values of 2 operands are equal or not, if affirmative then the condition becomes true. (A == B) isn’t true. |
!= | Checks if the values of 2 operands are equal or not, if values don’t seem to be equal then condition becomes true. (A != B) is true. |
> | Checks if the worth of the left quantity is bigger than the worth of the right quantity, if affirmative then the condition becomes true. (A > B) isn’t true. |
< | Checks if the worth of the left quantity is a smaller amount than the worth of the right quantity, if affirmative then the condition becomes true. (A < B) is true. |
>= | Checks if the worth of left quantity is bigger than or adequate to the worth of right quantity, if affirmative then condition becomes true. (A >= B) isn’t true.2 = 15,that is 0000 1111 |
Task Operators :-
There are following task directors upheld by C# −
Operator | Description Example |
---|---|
= | Simple assignment operator, Assigns worths from right facet operands to left facet operand C = A + B assigns value of A + B into C |
+= | Add AND assignment operator, It adds right quantity to the left quantity and assign the result to left operand C += A is cherish C = C + A |
-= | Subtract AND assignment operator, It subtracts right quantity from the left quantity and assign the result to left operand C -= A is cherish C = C – A |
*= | Multiply AND assignment operator, It multiplies right quantity with the left quantity and assign the result to left operand C *= A is cherish C = C * A |
/= | Divide AND assignment operator, It divides left quantity with the correct quantity and assign the result to left operand C /= A is cherish C = C / A |
%= | Modulus AND assignment operator, It takes modulus mistreatment 2 operands and assign the result to left operand folk music= A is cherish C = C nada A> 2 |
&= | Bitwise AND assignment operator C &= two is same as C = C & two |
^= | bitwise exclusive OR and assignment operator C ^= two is same as C = C ^ two |
|= | bitwise comprehensive OR and assignment operator C |= two is same as C = C | two |
Various Operators :-

There don’t seem to be several alternative vital directors together with sizeof, typeof and ? : upheld by C#.
Operator | Description Example |
---|---|
sizeof() | Returns the dimensions of an information sort. sizeof(int), returns 4. |
typeof() | Returns the kind of a category. typeof(StreamReader);& Returns the address of the associate variable. |
Administrator Precedence in C# :-
Administrator priority decides the gathering of terms in associate articulation. This influences assessment of associate articulation. bound directors have higher priority than others; for example, the rise administrator has higher priority than the growth administrator.For instance x = seven + three * 2; here, x is allotted thirteen, not twenty since administrator * has higher priority than +, therefore the primary assessment happens for 3*2 and later on seven is value-added into it.
Here, directors with the foremost noteworthy priority show up at the best purpose of the table, those with the smallest amount show up at the bottom. Within associate articulation, higher priority directors are assessed 1st. Show Examples
Category | Operator Associativity |
---|---|
Postfix | () [] -> . ++ – – Left to right |
Unary | + – ! ~ ++ – – (type)* & sizeof Right to left |
Multiplicative | * / % Left to right |
Additive | + – Left to right |
Shift | > Left to right |
Relational | < >= Left to right |
Equality | == != Left to right |
Bitwise | AND & Left to right |
Bitwise | XOR ^ Left to right |
Bitwise | OR | Left to right |
Logical | AND && Left to right |
Logical | OR || Left to right |
Conditional | ?: Right to left |
Assignment | = += -= *= /= %=>>= |
C# Comparison Operators :
Examination directors square measure used to research 2 qualities:
Operator Name | Example |
---|---|
== | Equivalent to x == y |
!= | Not equal x != y |
> | More noteworthy than x > y |
< | Less than x < y |
>= | More distinguished than or equivalent to x >= y |
C# Logical Operators :
Legitimate directors square measure used to make a decision the principle between factors or qualities:
Operator Name | DescriptionExample |
---|---|
&& | Intelligent Returns valid assumptive the 2 assertions square measure true x < five && x < ten |
|| | Intelligent Returns valid on the off likelihood that one in all the assertions is true x < five || x < four |
! | wise not Reverse the end result, returns bastard within the event that the end result is true !(x < five && x < 10) |
An operator may be an image that tells the compiler to perform specific mathematical or logical manipulations. C# has wealthy set of integral operators and provides the subsequent variety of variety of
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Assignment Operators
This tutorial explains the arithmetic, relational, logical, bitwise, assignment, and alternative operators one by one.
Arithmetic Operators:
Assume variable A holds ten and variable B holds twenty then −
Show Examples:
Operator | Description Example |
---|---|
+ | Adds 2 operands A + B = thirty |
– | Subtracts second quantity from the first A – B = -10 |
* | Multiplies each operands A * B = two hundred |
/ | Divides dividend by de-numerator B / A = two |
% | Modulus Operator ANd remainder of when an number division B you are a = zero |
++ | Increment operator will increase number price by one A++ = eleven |
— | Decrement operator decreases number price by one A– = nine |
Relational Operators
Following table shows all the relative operators supported by C#. Assume variable A holds ten and variable B holds twenty, then −
Show Examples:
Operator | Description Example |
---|---|
== | Checks if the values of 2 operands are unit equal or not, if affirmative then the condition becomes true. (A == B) isn’t true. |
!= | Checks if the values of 2 operands are unit equal or not, if values don’t seem to be equal then the condition becomes true. (A != B) is true. |
> | Checks if the worth of the left quantity is larger than the worth of the right quantity, if affirmative then the condition becomes true. (A > B) isn’t true. |
< | Checks if the worth of left quantity is a smaller amount than the worth of right quantity, if affirmative then condition becomes true. (A < B) is true. |
>= | Checks if the worth of left quantity is larger than or adequate the worth of right quantity, if affirmative then condition becomes true. (A >= B) isn’t true. |
Left to right
- Relational < >= Left to right
- Equality == != Left to right
- Bitwise AND & Left to right
- Bitwise XOR ^ Left to right
- Bitwise OR | Left to right
- Logical AND && Left to right
- Logical OR || Left to right
- Conditional ?: Right to left
- Assignment = += -= *= /= %=>>=
Addition: The ‘+’ operator adds 2 operands. as an example, x+y.
Subtraction: The ‘-‘ operator subtracts 2 operands. as an example, x-y.
Multiplication: The ‘*’ operator multiplies 2 operands. as an example, x*y.
Division: The ‘/’ operator divides the primary quantity by the second. as an example, x/y.
Modulus: The ‘%’ operator returns the rest once the initial quantity is split by the second. as an example, x%y.
The ones falling into the class of single Operators are:
Increment: The ‘++’ operator is employed to increment the worth of associate degree number. Once placed before the variable name (also known as pre-increment operator), its price is incremented instantly. as an example, ++x. And once it’s placed when the variable name (also known as post-increment operator), its price is preserved quickly till the execution of this statement and it gets updated before the execution of the ensuing statement. as an example, x + +.
Decrement: The ‘–‘ operator is employed to decrement the worth of associate degree number. Once placed before the variable name (also known as pre-decrement operator), its price is decremented instantly. as an example, –x.And once it’s placed when the variable name (also known as post-decrement operator), its price is preserved quickly till the execution of this statement and it gets updated before the execution of the ensuing statement. as an example, x–.
Conclusion :-
In this tutorial exercise, we have a tendency to seen with regards to the varied types of directors within the C# programming language. we have a tendency to seen with regards to the use and pictures of those directors.The number-crunching administrator is used by the program to perform basic pure mathematics tasks like enlargement, deduction, duplication, division, and so onSocial directors square measure those that square measure used to approve a association between the 2 operands like they’re equivalent, additional distinguished than, not specifically, so on Task directors square measure used for authorisation esteems to a variable.A most elementary illustration of the task administrator is “equivalent to”. Coherent directors square measure used for activity wise activities like AND, OR, NOT, so onAdministrators square measure widely used for saying conditions in dynamic proclamations, whereas utilizing circles or whereas activity mathematical tasks.