This post demonstrates available C# operators and their order of precedence.

In C#, we are allowed to create user-defined types for operators by using

Please share your thoughts on this post in the comments section.

C# provides a large set of operators, which are symbols that specify which type of operations to perform in an expression.A language may contain a fixed number of built-in operators (e.g. +, -, *, < etc. in C and C++), or it may allow the creation of

**user-defined operators**(e.g. F#, OCaml, Haskell).In C#, we are allowed to create user-defined types for operators by using

**operator overloading**, thus changing their meaning when applied. To know how to define your own operators – Operator OverloadingThe table lists the C# operators grouped in order of precedence fromOperators within each group havehighest to lowest.

**equal**precedence. For operators with equal precedence (e.g., + and -) are evaluated in an expression based on the**associativity**. Please follow this link to know the associativity of operators with equal precedence - Associativity of C# OperatorsOperator Category | Operators |
---|---|

Primary | x.y |

f(x) | |

a[x] | |

x++ | |

x-- | |

new | |

typeof | |

checked | |

unchecked | |

default(T) | |

delegate | |

sizeof | |

-> | |

Unary | +x |

-x | |

!x | |

~x | |

++x | |

--x | |

(T)x | |

await | |

&x | |

*x | |

Multiplicative | x*y |

x/y | |

x%y | |

Additive | x+y |

x-y | |

Shift | x< |

x>>y | |

Relational and type testing | x |

x>y | |

x<=y | |

x>=y | |

is | |

as | |

Equality | x==y |

x!=y | |

Logical AND | x & y |

Logical XOR | x ^ y |

Logical OR | x | y |

Conditional AND | x && y |

Conditional OR | x || y |

Null-coalescing | x ?? y |

Conditional | ?: |

Assignment and lambda expression | x=y |

x+=y | |

x-=y | |

x*=y | |

x/=y | |

x%=y | |

x&=y | |

x|=y | |

x^=y | |

x<<=y | |

x>>=y | |

=> |

**Note -**The arithmetic operators e.g. addition, subtraction can produce results outside the range of possible values causes an exception depending on the execution context, which can be checked or unchecked. To know more about checked and unchecked - Click herePlease share your thoughts on this post in the comments section.

It is really a great work and the way in which u r sharing the knowledge is excellent.

ReplyDeleteThanks for helping me to understand basic concepts. As a beginner in Dot Net programming your post help me a lot.Thanks for your informative article. Dot Net Training in chennai | Dot Net Training institute in velachery

Thanks for your informative articel .its very useful

ReplyDeletedot net training in velachery | dot net training in chennai

It is really a great work and the way in which u r sharing the knowledge is excellent.

ReplyDeleteThanks for helping me to understand basic concepts. As a beginner in dot net programming your post help me a lot.Thanks for your informative article.Dot Net training in chennai | Dot Net training institutes in chennai | Dot Net training in velachery