Caffeinated Coder
Book an appointment
Lesson 07 · Objects

Properties

A property looks like a field from outside, but it is a pair of methods called accessors: get runs on every read and set runs on every write. Follow a Thermostat object whose set uses Math.Clamp to keep its private field between 5 and 30, so writing 99 stores 30; then meet a computed, read-only property (86) and an auto-implemented one.

12 min9 steps5 questionsIntermediate
Fig 7 · Interactive
Loading figure…
or ← →

Quiz Unlocks after the last step.