What is the difference between public, private, and protected access modifiers?
What is the difference between public, private, and protected access modifiers?
25623-Aug-2021
Home / DeveloperSection / Forums / What is the difference between public, private, and protected access modifiers?
Ashutosh Kumar Verma
26-Aug-2021Access 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.