What protected internal access modifier
Define protected internal access modifier in c# and how it is differ from internal access modifier.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Sep 22, 2012, 6:03 PM
I believe there were two reasons for this:
1. The language designers didn't think it would be used much, if at all.
2. They couldn't think of a suitable name for it anyway :)
However, it is supported in C++/CLI ( as 'protected private') for anyone who uses that language.
Santhosh Kumar JayaramanPosted Sep 22, 2012, 10:58 AM
Protected- you can access it in child classes.
So protected internal will be a combination of both. You can access within the same assembly as well as child classes present inside other assembly.
Let me tell you smalll example.
I have assembly1, assembly2
In assembly1 i have a parent Class Vehicle.
In the same assembly i have a class Car derived from vehicle.
Now in assembly2 , i have class Bus derived from vehicle(Assembly1).
Now if i have 2 methods CalculateMileage, GetFuelCapacity
Calculate Mileage i declared it as internal access specifier and GetFuelCapacity i declared it as protectedinternal.
Now when i check the methods for Bus, i can see only GetFuelCapacity, thats because its declared as protected internal.
Hope this would help you to understand well..
Sukesh MarlaPosted Sep 22, 2012, 10:50 AM
==>Accessible anywhere in same assembly it is created + Sub classes in other assembly.
Check this is correct answer if it helped.