Access modifiers in C# are keywords used to define the accessibility or visibility of classes, methods, variables, and other members. They help control how and where these members can be accessed. Here's a concise overview of the main access modifiers in C#:
1. Public
2. Private
3. Protected
4. Internal
5. Protected Internal
6. Private Protected
Summary Table
Modifier |
Same Class |
Derived Class |
Same Assembly |
Other Assemblies |
public |
β |
β |
β |
β |
private |
β |
β |
β |
β |
protected |
β |
β |
β |
β |
internal |
β |
β |
β |
β |
protected internal |
β |
β |
β |
β (if derived) |
private protected |
β |
β |
β |
β |
These modifiers are essential for implementing encapsulation and controlling access to your code effectively.