What is Internal Access Modifier in C#?If you want
a type or a member of a type to be visible only within an assembly then
you will define it with internal access modifier.
To demonstrate it, follow the steps shown below: Create
the following class: Name the class as sampleAssembly.cs and Compile this class by specifying /target:library Create a new program called testClass.cs with the following code: public class
testClass { Compile
this program by specifying /reference:sampleAssembly.dll This is because,
you try to access internal member of sampleClass from a class which is
referencing the assembly but not belonging to that assembly. If the testClass
is also part of sampleAssembly then you can very well access sampleClass.member1
without any errors.
|