What is the difference between 'protected' and 'protected internal'?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
In C#, protected and protected internal both expose members beyond the declaring class, but they do not expose them to the same audience. protected is inheritance-based access, while protected internal is broader and allows access either through inheritance or from any code in the same assembly.
protected Means the Inheritance Chain
A protected member can be used inside the class that declares it and inside derived classes. Unrelated classes cannot access it directly, even if they live in the same project.
This compiles because Derived inherits from Base. If you tried to read Counter from a non-derived helper class, the compiler would reject it.
protected internal Means Same Assembly OR Derived Type
The phrase protected internal is easy to misread. It does not mean "accessible only when code is both protected and internal." In C#, it means access is granted when either condition is true:
- The code is in a derived class.
- The code is in the same assembly.
That makes it wider than plain protected.
If NonDerived is compiled into the same assembly, this works even though NonDerived does not inherit from Base. That is the core difference.
Think in Terms of Design Boundaries
The useful question is not "which modifier is more convenient right now?" It is "who should be allowed to depend on this member?"
Choose protected when the member exists for subclasses that extend the type's behavior. Choose protected internal when you also want same-assembly collaborators to use that member directly.
This is common in frameworks where the library assembly contains helper types, factories, or infrastructure that must coordinate closely with the base type. The tradeoff is tighter coupling inside the assembly. Once many unrelated classes can touch the member, it becomes harder to change later.
Compare It with private protected
C# also offers private protected, which is narrower. It allows access only from derived classes inside the same assembly. That gives you a useful spectrum:
- '
protected: derived classes anywhere' - '
protected internal: derived classes anywhere or same-assembly code' - '
private protected: derived classes in the same assembly only'
That comparison helps expose why protected internal is often misunderstood. It is the most permissive of the three in many real codebases.
Common Pitfalls
The most common mistake is assuming protected internal behaves like a restrictive combination of two keywords. In practice it is broader because the access rule is based on or.
Another issue is using protected internal when plain protected would have preserved a cleaner API boundary. Broader access feels convenient during implementation and becomes costly during maintenance.
Developers also sometimes forget the assembly part entirely and are surprised when a non-derived type in the same assembly can access the member.
Summary
- '
protectedallows access from the declaring class and derived classes.' - '
protected internalallows access from derived classes or from any code in the same assembly.' - The important difference is same-assembly access for non-derived types.
- '
private protectedis narrower and should not be confused withprotected internal.' - Prefer the narrowest modifier that still matches the intended design boundary.
Related reading
- What is the difference between StreamWriter.Flush and StreamWriter.Close?
- What is the difference between String and string in C?
- What is the difference between String.Empty and empty string?
- What is the difference between System.Speech.Recognition and Microsoft.Speech.Recognition?
- What is the difference between Task.Run and Task.Factory.StartNew
- What is the difference between the override and new keywords in C?
- What is the difference between using and await using? And how can I decide which one to use?
- What is the difference between using IDisposable vs a destructor in C?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.