Internal X public access modifier

Asked

Viewed 115 times

7

  1. When using public or international?
  2. Is there any advantage/disadvantage between them?
  • The answers to this question will tend to tell what the differences are between them and not to answer what has been asked. The reason is that differences will dictate its use and in the face of this its advantages/disadvantages.

1 answer

6


The access modifier public makes your method/property (or anything else) accessible from anywhere in your application (or others). This means that it will be possible to access the element even if it is an internal function of a library that is imported via reference.

The modifier internal makes the element can only be accessed inside that same Assembly, ie, the element will only be accessed inside the .exe or .dll that was created.

When using public or international?

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

Is there any advantage/disadvantage between them?

Another thing only the application developer can answer. Can the element be accessed outside the created Assembly? If so, use public, otherwise, use internal.

  • I only had to answer if Existe algum vantagem/desvantagem entre eles

  • 1

    Ready @rubStackOverflow

Browser other questions tagged

You are not signed in. Login or sign up in order to post.