WHAT IS DATA HIDING?

Anupam Mishra

Total Post:135

Points:949
Posted by  Anupam Mishra
C#  .NET  OOPS 
C#
 504  View(s)
Ratings:
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)
  1. Manoj Bhatt

    Post:154

    Points:1086
    Re: What is Data Hiding?

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!