Core C#

Operators

This is a table of the operators available in the C# programming language.

Operators (Ordered by Precedence)
Symbol Description Example Arity Associativity Overloadable
Primary Operators
. Member Access qObj.Member Binary Left No
?. Null Conditional Member Access qObj?.Member Binary Left No
?[] Null Conditional Index Access a?[i] Binary Left No
() Function Invocation f() Unary Left No
[] Array Indexer a[i] Binary Left Yes
++ Postfix Increment i++ Unary Left Yes
-- Postfix Decrement i-- Unary Left Yes
new Allocation new T() Unary Left No
typeof Get the Type for a type typeof(T) Unary Left No
checked Check integer calculations for overflow checked(i+j) Unary Left No
unchecked Disable check for overflow unchecked{...} Unary Left No
default Get the default value for a type default(T) Unary Left No
delegate Create a handler for an event delegate(...){...} Unary Left No
sizeof Size of an unmanaged type in bytes sizeof(T) Unary Right No
-> Pointer Dereference qpObj->Member Binary Left No
Unary Operators
+ Positive +X Unary Right Yes
- Negation -X Unary Right Yes
! Logical Not !P Unary Right Yes
~ Bitwise Complement ~B Unary Right Yes
++ Prefix Increment ++i Unary Right Yes
-- Prefix Decrement --i Unary Right Yes
() Type Cast (T)qObj Unary Right No
await Wait for a task await f() Unary Right No
& Address of &qObj Unary Right No
* Dereference *qpObj Unary Right No
Arithmetic Operators
* Multiplication X*Y Binary Left Yes
/ Division X/Y Binary Left Yes
% Modulus X%Y Binary Left Yes
+ Addition X+Y Binary Left Yes
- Subtraction X-Y Binary Left Yes
Bitwise-Shift Operators
<< Shift Left (zero fill) i << b Binary Left Yes
>> Shift Right (sign fill signed types) i >> b Binary Left Yes
Relational Operators and Type Testing
< Less Than X < Y Binary Left Yes
> Greater Than X > Y Binary Left Yes
<= Less Than Equal X <= Y Binary Left Yes
>= Greater Than Equal X >= Y Binary Left Yes
is Type Check qObj is T Unary Left No
as Type Conversion qObj as T Unary Left No
Equality Operators
== Is Equal to X == Y Binary Left Yes
!= Is Not Equal to X != Y Binary Left Yes
Bitwise Logical Operators
& Bitwise Logical And B1 & B2 Binary Left Yes
^ Bitwise Logical Xor B1 ^ B2 Binary Left Yes
| Bitwise Logical Or B1 | B2 Binary Left Yes
Logical Operators
&& Logical And P && Q Binary Left No
|| Logical Or P || Q Binary Left No
Null-Coalesing Operator
?? Returns the first object if it is not null; otherwise, the second qObj1 ?? qObj2 Binary Left No
Conditional Operator
?: Returns x if P is true and Y if P is false P ? X : Y Ternary Right No
Assignment and Lambda Operators
= Assignment X = Y Binary Right No
+= Assignment + X += Y Binary Right No
-= Assignment - X -= Y Binary Right No
*= Assignment * X *= Y Binary Right No
/= Assignment / X /= Y Binary Right No
%= Assignment % X %= Y Binary Right No
&= Assignment & X &= Y Binary Right No
|= Assignment | X |= Y Binary Right No
^= Assignment ^ X ^= Y Binary Right No
<<= Assignment << X <<= b Binary Right No
>>= Assignment >> X >>= b Binary Right No
=> Lambda Operator X => Y Binary Left No
 
 

© 2007–2024 XoaX.net LLC. All rights reserved.