You must Sign In to post a response.
  • Category: .NET

    Differnce between internal & protected internal access specifier ?

    mmm...I may be confussed, but this is what I understand...

    protected -> the class itself and any inheriting class can access this method or propetry

    internal -> ANY class within same assembly can access this method/property, meaning any class within the same VS Project, exe, or dll can access it, whether it's inheriting it or not can get to it

    protected internal -> the class itself (where it's declared), the inheriting class(es), and just like internal, it can be access throughout our assemby by any class or part of assembly

    based on the above, what is the real need for "protected internal"? If I want a method to be accessible by the base class, all inheriting classes, and throughout the assembly as well, then I can just declare it internal, why dcelare it protected internal? what does it gain me, other than the extra keyword?
  • #348899

    check this this might help

    and I doubt u have already seen it

    Kartheek Reddy .N / GGK Technologies Inc –

  • #348978

    Let me Share one single point on this...

    What you say is correct, when you are thinking of in one particular Assembly But the scenario changes with multiple assemblies.

    Answer to your Point: what is the Need for protected internal?

    Let me describe the scenario.

    I have a classBase with somemethod which is needed in myAssembly,
    and in someclasses of other other Assemblies which inherits the Base class
    --> then what is the Access we have for Some Method() in order to access it in MyAssembly and OtherAssemly

    Delete Attachment

  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.