Internal is added to the front of the class so that only the same assembly file can be referenced. The common use of internal is based on component development, which facilitates communication between components without exposing the structure to the outside world.
Routines inside, assembly1 defined BaseClass is a internal class, after the output becomes DLL, assembly2 come to reference it, this time again to want to quote internal class will not be.
The internal keyword is a access modifier for types and type. Internal members is accessible only within files in the same assembly. For more information in assemblies, see Components and Assemblies.
A common use of internal access was in component-based development because it enables a group of components to cooperate in A private manner without being exposed to the rest of the application code. For example, a framework for building graphical user interfaces could provide Control and Form classes that cooperate usin G members with internal access. Since these members were internal, they was not exposed to code that was using the framework.
It is an error to reference a member with internal access outside the assembly within which it was defined. Caution an internal virtual method can is overridden in some languages, such as textual Microsoft intermediate language (M SIL) using Ilasm.exe, even though it cannot be overridden using C #.
For a comparison of internal with the other access modifiers, see accessibility levels.
Example
This example contains the files, Assembly1.cs and Assembly2.cs. The first file contains an internal base class, BaseClass. In the second file, a attempt to access the member of the base class would produce an error.
// Assembly1.cs// compile with: /target:libraryinternal class BaseClass { public static int IntM = 0;}
-file Assembly2.cs
// Assembly2.cs// compile with: /reference:Assembly1.dll// CS0122 expectedclass TestAccess { public static void Main() { BaseClass myBase = new BaseClass(); // error, BaseClass not visible outside assembly }}
Internal access level [C #]