Access modifier Internal X public

7
  • When to use public or internal?
  • Is there any advantage / disadvantage between them?
  • asked by anonymous 17.11.2015 / 22:24

    1 answer

    6

    The public access modifier causes your method / property (or anything else) to be accessed from anywhere in your (or other) application. This means that it will be possible to access the element even though it is an internal function of a library that is imported by reference.

    The internal f modifier causes the element to only be accessed within that same assembly, meaning the element will only be accessed within .exe or .dll that was created.

      

    When to use public or internal?

    Only you can decide. Although it is more common to use internal on elements that can not be accessed / modified by another assembly (in case you are developing a dll ).

      

    Is there any advantage / disadvantage between them?

    Another thing that only the application developer can answer. Can the element be accessed outside of the assembly that was created? If yes, use public , otherwise use internal .

        
    17.11.2015 / 22:29