1/29
C#
Name  | Mastery  | Learn  | Test  | Matching  | Spaced  | 
|---|
No study sessions yet.
=
Assigns a value to a variable. Example: int x = 5; x now holds 5
+
Adds numbers or joins text. Example: int sum = 2 + 3; sum is 5
-
Subtracts numbers. Example: int diff = 5 - 2; diff is 3
*
Multiplies numbers. Example: int prod = 3 * 2; prod is 6
/
Divides numbers. Example: int div = 6 / 2; div is 3
%
Gives remainder after division. Example: int rem = 5 % 2; rem is 1
++
Increases a number by 1. Example: x++; x becomes 6
--
Decreases a number by 1. Example: x--; x becomes 5
==
Checks if two things are equal. Example: bool yes = (x == 5); yes is true
!=
Checks if two things are NOT equal. Example: bool no = (x != 5); no is false
>
Checks if left is bigger than right. Example: bool big = (x > 3); true
Checks if left is smaller than right. Example: bool small = (x < 10); true
=
Checks if left is bigger or equal. Example: bool ge = (x >= 5); true
Checks if left is smaller or equal. Example: bool le = (x <= 5); true
!
Flips true/false. Example: bool notTrue = !true; false
&&
Both must be true. Example: bool both = (x > 3 && x < 10); true
||
One or both are true. Example: bool either = (x < 3 || x > 4); true
+=
Adds a number to a variable. Example: int x = 5; x += 2; x is now 7
-=
Subtracts a number from a variable. Example: int x = 5; x -= 2; x is now 3
*=
Multiplies a variable by a number. Example: int x = 5; x *= 2; x is now 10
/=
Divides a variable by a number. Example: int x = 10; x /= 2; x is now 5
%=
Replaces a variable with its remainder after division. Example: int x = 5; x %= 2; x is now 1
Shifts bits left (multiply by 2 for each shift). Example: int x = 2; x = x << 1; x is now 4
>
Shifts bits right (divide by 2 for each shift). Example: int x = 4; x = x >> 1; x is now 2
&
Bitwise AND; compares bits, 1&1=1 else 0. Example: int x = 6 & 3; x is 2
|
Bitwise OR; compares bits, 1|0=1. Example: int x = 6 | 3; x is 7
^
Bitwise XOR; 1 if bits are different. Example: int x = 6 ^ 3; x is 5
~
Bitwise NOT; flips all bits. Example: int x = ~6; x is -7
=>
Lambda; a shortcut to write a simple function. Example: Func