C# Internal Access Modifier

Using internal member

The internal modifier declares that a member is known throughout all files in an assembly, but unknown outside that assembly. The protected internal access level can be given only to class members. A member declared with protected internal access is accessible within its own assembly or to derived types.


using System; /*from   w w w  . j  a va 2 s  .c om*/
 
class InternalTest { 
  internal int x; 
} 
 
class MainClass { 
  public static void Main() { 
    InternalTest ob = new InternalTest(); 
 
    ob.x = 10; // can access -- in same file 
 
    Console.WriteLine("Here is ob.x: " + ob.x); 
 
  } 
}

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. What is a class
  2. How to create a class
  3. An example class
Home »
  C# Tutorial »
    C# Types »
      C# Access Modifier
C# Access Modifiers
C# Private Access Modifier
C# Public Access Modifier
C# Protected Access Modifier
C# Internal Access Modifier