Home c# C # access modifiers

C # access modifiers




Let’s say, I set an Internal access modifier class, and a variable in this Public class. The question, this variable will have an Internal access modifier (as a class access modifier) ​​or public (as a variable access modifier)?

Answer 1, Authority 100%

To Public Variables, you can contact from any build place , where Internal is announced.
Of course, you still need to get an instance of the class.


Modifier INTERNAL by class means that it is impossible to use it from the outside of the assembly, in the kitter it is declared (that is, it is impossible to create a variable with such a type in another assembly, call the constructor This class, or inherit from it, as well as contact its static member).
At the same time within the same assembly in which the class is notified cannot be made Public Member Public Class returning an instance of Internal Class – a compiler takes care of this and Throw CS0050
Ultimately, this means that in other assemblies it is impossible to get an instance of Internal class.

Modificor Public The class member means that anyone can contact him, but only through an instance of the class.

In the documentation you can read: Internal (C # Reference ) .

Previous articleHow JavaFx Controller
Next articleRest API

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions