Search code examples
c#.netinternalprotectedaccess-modifiers

Is there a difference between Protected Internal and Internal Protected?


public class TestClass
{
    protected internal int FieldA;
    internal protected int FieldB;    
}

Is there a difference between Protected Internal and Internal Procted Members?


Solution

  • Is there a difference between protected internal and internal protected members?

    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?