Previously, we went through the following concepts in Chapter 2, Understanding Classes, Structures, and Interfaces, and Chapter 3, Understanding Object-Oriented Programming:
- Accessing modifiers and how they help us to control access to methods and fields in the same class, in the same assembly, and in the derived classes
- Encapsulation and how it helps us to group together related fields and methods together in the same object
However, there is another concept in encapsulation called properties, which makes sure that no one can have direct access to the data fields outside the class. This helps us to make sure that we have control over the modification of the data fields.
A property is very similar to the field of a class. Just like the field of a class, it has a type, name, and access modifier. However, what makes it different is the presence of accessors...