Recall & Review
beginner
What is a value type in C#?
A value type stores the actual data directly. When you assign it to another variable, a copy of the data is made.
Click to reveal answer
beginner
What is a reference type in C#?
A reference type stores a reference (or address) to the actual data in memory. Assigning it to another variable copies the reference, not the data.
Click to reveal answer
beginner
How does changing a value type variable affect another variable it was assigned to?
It does not affect the other variable because each has its own copy of the data.
Click to reveal answer
beginner
How does changing a reference type variable affect another variable it was assigned to?
Changing the data through one variable affects the other because both variables point to the same data in memory.
Click to reveal answer
beginner
Give an example of a value type and a reference type in C#.
Value type example: int, struct. Reference type example: class, string.
Click to reveal answer
Which of these is a value type in C#?
✗ Incorrect
int is a value type. string, class, and array are reference types.
What happens when you assign one reference type variable to another?
✗ Incorrect
Assigning a reference type copies the reference, so both variables point to the same data.
If you change a value type variable after assigning it to another, what happens to the other variable?
✗ Incorrect
Value types are copied, so changing one does not affect the other.
Which of these is stored on the stack in C#?
✗ Incorrect
Value types are typically stored on the stack, while reference types are stored on the heap.
Which keyword defines a value type in C#?
✗ Incorrect
struct defines a value type, while class defines a reference type.
Explain the difference between value types and reference types in C# using a real-life analogy.
Think about copying a physical object versus sharing a pointer to it.
You got /5 concepts.
Describe what happens in memory when you assign one reference type variable to another and then modify the data.
Focus on shared memory and references.
You got /4 concepts.