Operators and Symbols C#

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/29

flashcard set

Earn XP

Description and Tags

C#

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

30 Terms

1
New cards

=

Assigns a value to a variable. Example: int x = 5; x now holds 5

2
New cards

+

Adds numbers or joins text. Example: int sum = 2 + 3; sum is 5

3
New cards

-

Subtracts numbers. Example: int diff = 5 - 2; diff is 3

4
New cards

*

Multiplies numbers. Example: int prod = 3 * 2; prod is 6

5
New cards

/

Divides numbers. Example: int div = 6 / 2; div is 3

6
New cards

%

Gives remainder after division. Example: int rem = 5 % 2; rem is 1

7
New cards

++

Increases a number by 1. Example: x++; x becomes 6

8
New cards

--

Decreases a number by 1. Example: x--; x becomes 5

9
New cards

==

Checks if two things are equal. Example: bool yes = (x == 5); yes is true

10
New cards

!=

Checks if two things are NOT equal. Example: bool no = (x != 5); no is false

11
New cards

>

Checks if left is bigger than right. Example: bool big = (x > 3); true

12
New cards
<

Checks if left is smaller than right. Example: bool small = (x < 10); true

13
New cards

=

Checks if left is bigger or equal. Example: bool ge = (x >= 5); true

14
New cards

Checks if left is smaller or equal. Example: bool le = (x <= 5); true

15
New cards

!

Flips true/false. Example: bool notTrue = !true; false

16
New cards

&&

Both must be true. Example: bool both = (x > 3 && x < 10); true

17
New cards

||

One or both are true. Example: bool either = (x < 3 || x > 4); true

18
New cards

+=

Adds a number to a variable. Example: int x = 5; x += 2; x is now 7

19
New cards

-=

Subtracts a number from a variable. Example: int x = 5; x -= 2; x is now 3

20
New cards

*=

Multiplies a variable by a number. Example: int x = 5; x *= 2; x is now 10

21
New cards

/=

Divides a variable by a number. Example: int x = 10; x /= 2; x is now 5

22
New cards

%=

Replaces a variable with its remainder after division. Example: int x = 5; x %= 2; x is now 1

23
New cards
<<

Shifts bits left (multiply by 2 for each shift). Example: int x = 2; x = x << 1; x is now 4

24
New cards

>

Shifts bits right (divide by 2 for each shift). Example: int x = 4; x = x >> 1; x is now 2

25
New cards

&

Bitwise AND; compares bits, 1&1=1 else 0. Example: int x = 6 & 3; x is 2

26
New cards

|

Bitwise OR; compares bits, 1|0=1. Example: int x = 6 | 3; x is 7

27
New cards

^

Bitwise XOR; 1 if bits are different. Example: int x = 6 ^ 3; x is 5

28
New cards

~

Bitwise NOT; flips all bits. Example: int x = ~6; x is -7

29
New cards

=>

Lambda; a shortcut to write a simple function. Example: Func

30
New cards