Protection level of a class is internal in .NET

Protection level of a class is internal by default

I was working with a young developer and had an fun discussion about protection levels. It is easy to forget default protection levels (access modifier). Classes are internal by default in .NET. Internal means that the class is visible to any code inside the assembly but not outside it.

Class members, methods, properties are private. What happens when my class member is public? In the assembly, the class member will have a maximum protection level of the lowest possible, which will be Internal. Why? Class member belongs to a class and the class has a default protection level of internal. Therefore the class member will have maximum protection level of internal in that assembly.

Nested classes or structs are private as well.

Interface and Enum are…public!