Getters, Setters and Properties
In this lesson, we will look into the getters, setters and properties in C#.
We'll cover the following...
An Analogy
Consider the vending machine example. In this machine, there are several components working together at a micro level to make the vending machine functional at a macro level. There may be a display screen whose purpose is to provide an interface to the users. There may be a product dispenser whose purpose is to dispense products. There may be a cash collector whose purpose is to collect cash from the customers.
What we want to emphasize here is that there are many components providing their specific functionalities that don’t know each other’s internal implementation or working details. The screen doesn’t need to know how the cash collector component is internally keeping track of the total money collected until now, nor does the cash collector need to know how the screen is ...