Caffeinated Coder
Book an appointment
Lesson 03 · Basics

Value types and reference types

Every C# type is a value type or a reference type, and the difference shows up the moment you assign one variable to another. Follow an eight-line program through memory: copying an int copies the value, so the two variables stay independent; copying a reference to a Box object copies only the arrow, so two variables share one object and a change made through one is seen through the other. The program prints 5 9 9.

12 min9 steps5 questionsBeginner
Fig 3 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.