Encapsulation in C#

You want to know the purpose of encapsulation in OOP and how it works in C#.

There are two reasons for encapsulation. The main one is information hiding. Information hiding is enforced by restricting direct access to an object’s members. The second reason for encapsulation is grouping related data and methods together. A “capsule” is created when data and methods (the operations performed on the data) are coupled.

In C#, encapsulation is implemented through the use of access modifiers and properties.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s