Access modifiers : In c#, the access modifier 'public', 'private' and 'protected' are used to access data members and methods of class. With the use of access modifier we access methods and variables of a class like as-
1- Public: Public access modifier provide facilities to access methods properties and fields of base class in derived class or in other file in project.
2- Private: Private access modifier did not allow to access properties, methods and fields of base in other derived class. Which methods or variables declare as private then we can use them within same class.
3- Protected: Protected access modifiers provide facility to access methods, properties and fields of base class within same class or its derived class only.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Access modifiers : In c#, the access modifier 'public', 'private' and 'protected' are used to access data members and methods of class. With the use of access modifier we access methods and variables of a class like as-
1- Public: Public access modifier provide facilities to access methods properties and fields of base class in derived class or in other file in project.
2- Private: Private access modifier did not allow to access properties, methods and fields of base in other derived class. Which methods or variables declare as private then we can use them within same class.
3- Protected: Protected access modifiers provide facility to access methods, properties and fields of base class within same class or its derived class only.