Caffeinated Coder
Book an appointment
Lesson 08 · Objects

Structs and records

A struct is a value type: its variable holds the data itself, so assigning it copies every field. A record is a type the compiler fills in for you: from one line it writes a constructor, init-only properties, value equality, a readable ToString and support for with. Follow one program as a struct is copied and changed, and as record objects land on the heap, get copied with with, print themselves and compare equal by value.

14 min9 steps5 questionsIntermediate
Fig 8 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.