What is the difference between public, private, and protected access modifiers?
What is the difference between public, private, and protected access modifiers?
Software Developer
Hi, my self Ravi Vishwakarma. I have completed my studies at SPICBB Varanasi. now I completed MCA with 76% form Veer Bahadur Singh Purvanchal University Jaunpur. SWE @ MindStick | Software Engineer | Web Developer | .Net Developer | Web Developer | Backend Engineer | .NET Core Developer
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.