Unary minus operator for signed integers:
r1 int = -i r2 int = -(-i)
Addition, subtraction, multiplication, division and modulus (remainder) operator:
r1 int = a + b r2 int = a - b r3 int = a * b r4 int = a / b r5 int = a % b
Multiplicative operators (*, /, %) precede the additive operators (+, -).
OverflowError
a int = int.MaxValue + 1
DivideByZeroError
a int = 0 b int = 100/a
And, or, exclusice or (xor)
r1 int = a & b r2 int = a | b r3 int = a ^ b
Complement
r int = ~a
Left shift, right shift
r1 int = a << 4 r2 int = a >> 2
And, or, exclusice or (xor)
r1 bool = a & b r2 bool = a | b r3 bool = a ^ b
Negation
r bool = !a
Short-circuiting
r1 bool = a && b r2 bool = a || b
Concatenation
r string = a + b
Equality, inequality, greater than, less than, greater than or equal, less than or equal, pointer equality, pointer inequality
r1 bool = a == b r2 bool = a != b r3 bool = a > b r4 bool = a < b r5 bool = a >= b r6 bool = a <= b
Pointer equality, pointer inequality
r1 bool = a === b r2 bool = a !== b
Case-insensitive (simple ordinal) string equality
a ^== b
nullableStr string? = null str string = nullableStr ?? "Default value"
this.doSomething(strA ?? "Default value", 123)
str string = i > 2 ? "a" :: "b"
this.doSomething(i > 2 ? "a" :: "b", 123)
Member access, index operator
r1 = a.b r2 = a[b]
str object = "abc" b bool = str is int
The as operator will always lead to a nullable type
o object = "My string" str string? = o as string
This will lead to null:
o object = 123 str string? = o as string
o object = "My string" str string = (string)o
myInt int = 123 str string = nameof(myInt)
type Type = typeof(MyClass)
() a.b a[b] +a -a !a ~a a*b a/b a%b a+b a-b a<<b a>>b a<b a>b a<=b a>=b is a==b a!=b a===b a!==b a^==b a&b a^b a|b a&&b a||b a??b a?b::c