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#.
- Public:- A member is accessible from everywhere.
- Private:- A member accessible only from the class.
- Protected:- A member accessible only from the class and its derived classes.
- Internal:- Accessible only from the same assembly or class library. Outside no one even knows about the existence of this class.
- Protected internal:- Accessible only from the same assembly or any derived classes.