rockstar - value vs reference Flashcards

1
Q

Value types - Allocation

A
  • Allocated on the stack
  • When you declare a value type variable, data is stored directly in memory where the variable is created
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Value types - Passing to methods

A
  • Passes copy of data
  • Changes to value within the method does not affect original variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Reference Types - Allocation

A
  • Allocated on the heap
  • When you declare a reference type variable, a reference (memory address) to the actual data is stored on the heap
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Reference Types - Passing to methods

A
  • Passes reference address
  • Changes to variable will change the original value because it references the same memory location in the method
How well did you know this?
1
Not at all
2
3
4
5
Perfectly