Dot Net Framework support four types of Access Modifiers, they are
- Private
- Protected
- Inline
- Public
Now let’s see them one by One
- Private Modifiers :-
- Private Members, Variables, classes, and methods are only available within the class.
- We can’t instantiate Object of the private Class.
- We cannot create class with private access modifier but we can create class as private which is a internal class of another class, and which is available anywhere in the parent class.
![]() |
| Fig. How Private Class wors in Parent class |
- Protected Members, Variables, classes, and methods are only available within the inheritance.
![]() |
| Fig. Error in Calling Explicit protected method |
- Class "Employee" inheriting class "Person", "GetName ()" mothod of "Person" class now available in the class "Employee".
- Protected can be available outside the assemble also but only in Inheritace chain.
- we can not create protected class directely, if you want a class to be protected it should be internal class.



No comments:
Post a Comment