Encapsulation is the process of wrapping method and attributes into single unit and hiding unnecessary data by using access modifiers.
public class A { Private int Id; Private string _Name; Public string Name { get { return _Name;} set{_Name = value;} } Public void SaveandPrint() { Save(); Print(); } Private void Save() { // Call the ADO.Net method to save data } Private void Print() { // create the object of report and print data } }
Here the object expose only the information of SaveandPrint(). But internally it is split into two methods as Save() & Print() and it is not exposed to end user. Also it wrap the variable and function into single unit called class. While creating object also it keep in a single unit.