1

Internal types or members are accessible only within files in the same assembly,

I'm afraid that I don't know exactly what does assembly mean in C#.

Could you please explain it's definition when defining member as internal?

mshwf
  • 7,009
  • 12
  • 59
  • 133

2 Answers2

3

An assembly equals the .DLL or .EXE produced by all the compilation units (files) included in the project that creates said assembly.

So when a class or class member is marked internal then that means it is accessible only by code that is included in that assembly.

GreatAndPowerfulOz
  • 1,767
  • 13
  • 19
  • Assemblies can also be dynamically created without persisting to a DLL or executable, see https://stackoverflow.com/questions/2394699/net-dynamic-assemblies. – Preston Guillot Jun 30 '16 at 23:49
3

Each project (.csproj file) in a solution (.sln file) will produce an assembly. (each .exe file or .dll file is considered an assembly)

When a member is internal it is seen as public to all other classes in the same project but it is seen as private to all classes outside of the project.

Scott Chamberlain
  • 124,994
  • 33
  • 282
  • 431
  • What are the cases I need to use public member in other program? – mshwf Jul 01 '16 at 08:50
  • 1
    @MohamedAhmed when you want other projects to be able to call your code. For example you are making a DLL for other people to use, all the functions that people can call will need to be public. – Scott Chamberlain Jul 01 '16 at 13:32