
C# Access Modifiers: protected vs. protected internal
This article clarifies the key differences between the protected and protected internal access modifiers in C#. These modifiers control the visibility and accessibility of class members (fields, methods, properties, etc.).
protected Modifier
The protected modifier limits access to members within the declaring class itself and its derived classes. In essence, only the class and its descendants can access protected members. Classes outside the inheritance hierarchy, even within the same assembly, cannot directly access them.
protected internal Modifier
The protected internal modifier expands access beyond the protected modifier. It combines the accessibility of both protected and internal modifiers:
Crucially, classes in external assemblies cannot directly access protected internal members. Access from an external assembly must be mediated through an instance of a derived class.
Summary Table:
| Access Modifier | Accessibility Scope | ||||||
|---|---|---|---|---|---|---|---|
|
Declaring class and its derived classes | ||||||
| Declaring class, derived classes, and classes within the same assembly |
protected internalThe
The above is the detailed content of What's the Difference Between C#'s `protected` and `protected internal` Access Modifiers?. For more information, please follow other related articles on the PHP Chinese website!
What is ESD file?
What is the article tag used to define?
How to solve parsererror error
How to solve the problem of black screen after turning on the computer and unable to enter the desktop
How to configure jsp virtual space
Complete collection of SQL query statements
what is css
what is adobe flash player