Home > DeveloperSection > Forums > What is Data Hiding?
Anupam Mishra

Total Post:135

Points:949
Posted on    January-12-2016 11:26 PM

 C# C#  .NET  OOPS 
Ratings:


 1 Reply(s)
 291  View(s)
Rate this:
I have basic doubts regarding Data(or Information) Hiding.  What is Data Hiding?
How to implement in C#? What is the difference/relation between Data Hiding and Encapsulation?(Both looks similar)


Manoj Bhatt
Manoj Bhatt

Total Post:153

Points:1079
Supported
Posted on    January-13-2016 5:50 AM

Encapsulation is more about keeping a group of code as a discreet work unit but it also has data hiding because you only expose "the method" rather than its inner workings to other classes. Encapsulating leads to data hiding, so that's why it sounds similar. 
Data hiding on its own it by only marking those things as a public scope which you want external classes to interact with, and private otherwise.  If you don't want other classes or only certain classes to use, you can also use private (current class only), protected (current and children), and internal (treated as public to other classes in the same assembly, private to outside assembly classes) to prevent other classes beyond a certain scope from using your methods/properties/classes.

Don't want to miss updates? Please click the below button!

Follow MindStick