Use of Accessibility Modifiers

C# provides facilities for full control over who can see and use classes and class members. This is done through class accessibility modifiers. Proper use of accessibility modifiers can protect the implementation of code and help to provide a clean interface.

For instance, a class may have a private field and provide a public accessor to external users, who have no need to know the nature of that field or how you use it. Furthermore, this practice enables the option to change the nature of that field later on, without causing the external user's code to break.

Accessibility modifiers also allow management of user interfaces. They can be used to expose certain class members to users who assist them in using a class ...

Get C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.