Encapsulation
Encapsulation is defined as binding data and code that manipulates it together in a single unit. Data is privately bound within a class without direct access from the outside of the class. All objects that need to read or modify the data of an object should do it through the public methods that a class provides. This characteristic is called data hiding and makes code less error-prone by defining a limited number of entry points to an object's data.
Let's take a look at the Employee
class here:
public class Employee { private string name; private double salary; public string Name { get { return name; } set { name = value; } } public double Salary { ...