public class TestClass
{
protected internal int FieldA;
internal protected int FieldB;
}
Is there a difference between Protected Internal and Internal Procted Members?
Is there a difference between
protected internalandinternal protectedmembers?
There is no difference between them.
protected internal means protected OR internal.
internal protected means internal OR protected.
The type or member can be accessed by any code in the assembly in which it is declared, or from within a derived class in another assembly. Access from another assembly must take place within a class declaration that derives from the class in which the protected internal element is declared, and it must take place through an instance of the derived class type.
Of the two, protected internal is commonly used. There is no reference to internal protected on the MSDN page about Access Modifiers.
Also check out Phil Haack's blog post What Does Protected Internal Mean?
No, no difference. You can declare them in any order you want. Just like you can declare static before or after the access modifier.
The only real difference should be what you and your team decide on. Typically you'll want to stick to one style to avoid confusion or assumptions, or at least make things consistent when reading it.
EDIT: Though, now that I think of it, I don't recall seeing "internal protected" often. On the MSDN page for access modifiers, it does list it as "protected internal", so maybe stick with that as it may be considered "more standard".
No, there is not.
Both variants define a member that is accessible from the same assembly AND from descendant classes.
it's a bitwise operation with a logical "OR" => Internal : from the same assembly. protected : from a derived class. "protected AND internal" is no sense :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With