AccessModifier - VishalBhanderi31/C-Sharp-OOPS GitHub Wiki

Try to remember the example of BlackBox and DVD player. Only a limited visibility from the outside, But there is a lot of magic happening inside.

For limiting the visibility of an object from outside, We are using various five access modifiers in c#.

  1. Public:- A member is accessible from everywhere.
  2. Private:- A member accessible only from the class.
  3. Protected:- A member accessible only from the class and its derived classes.
  4. Internal:- Accessible only from the same assembly or class library. Outside no one even knows about the existence of this class.
  5. Protected internal:- Accessible only from the same assembly or any derived classes.