C# Encapsulation

tutorial and example
tutorial and example

Encapsulation is a mechanism in which we wrap the data into a single unit called class. By Encapsulation, Data alteration is not possible through unknown sources. The data can only be accessed through getter methods.

Encapsulation increases the maintenance of the code which enhances usability. We can access the class data by the getter and setter methods only. We can’t access the data directly.

Let’s see an example of encapsulation.

Output