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 operator overloading, thus changing their meaning when applied. To know how to define your own operators – Operator Overloading
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 here
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 Overloading
The table lists the C# operators grouped in order of precedence from highest to lowest.Operators within each group have 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# Operators
Operator 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 here
Please share your thoughts on this post in the comments section.
The exceptions should be taken into consideration, as you've pointed out.
ReplyDeletebetmatik
ReplyDeletekralbet
betpark
tipobet
slot siteleri
kibris bahis siteleri
poker siteleri
bonus veren siteler
mobil ödeme bahis
1QH1
شركة تنظيف سجاد وموكيت بالاحساء driMVDIW2l
ReplyDelete