The internal access modifier can be applied to
Classes and it’s member
Structure and it’s member
This way it is available to all the files within that assembly.
Particularly useful when creating software components.
It can be used in conjunction with protected to produce
protected internal access modifier
It can be applied only to
It is available withing it’s own assembly or to derived types.
Say if we create an Class Library which has a class like
public class MyClass
And then you create
Now we create new project say a windows application and add a refrence to that dll
And can create the object of that class lik
MyClass my=new MyClass();
this works fine,
now if we modify the definition of the class by replacing public with internal and update the assembly
internal class MyClass
This time if we try to create the object of MyClass which is inside our referenced assembly
The error which we will get is
MyClass is inaccessible due to its protection level.
That’s why they are basically used in component development so that any other class couldn’t be able to access it i.e. create objects of it.