Internal

What Does Internal Mean?

Internal, in C#, is a keyword used to declare the accessibility of a type or type member such that the access is limited to the assembly in which it is declared.

Advertisements

An internal modifier is used to prevent the use of a public modifier, which allows access to other assemblies wherever necessary. An internal modifier, therefore, is useful in implementing the concept of encapsulation in object-oriented programming at the assembly level. It is used in larger programs where information hiding across program boundaries can improve maintainability and security.

Internal is most often used in component-based development by allowing a specific group of components to communicate in a private manner and prevent access to the code that is not relevant to this group. Internal modifiers enable the access of members of an assembly from the friend assemblies that are designed for specific reasons such as unit testing, extensions to class libraries, etc.

Techopedia Explains Internal

Internal is one of the access modifiers that limits the access to types defined within the current project assembly. The default accessibility of classes and structs that are declared within a namespace or at the top level of a compilation unit and not within other types is internal.

For example, while developing a graphical user interface (GUI) application that involves customized GUI elements such as windows, forms, controls, etc., they can be specified with internal accessibility so that they cooperate privately without being exposed to the code that is using these elements.

Referencing a member with internal access from outside the assembly in which it is declared results in a compiler error. While using the internal members of an assembly that need to be accessed from a friend assembly, the name of the friend assembly should be specified with the attribute, InternalsVisibleToAttribute in the assembly where the internal members are defined.

An internal virtual method cannot be overridden in C#.

Advertisements

Related Terms

Latest DevOps Terms

Related Reading

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…