A compiler error message: the declarations that cannot be displayed for elements defined in the namespace are private, protected, and protected internal.
The following elements can be defined in a namespace: class, struct, delegate, interface, and enum)
MSDN prompt: protected internal accessibility means being protected "or" internal, rather than being protected "and" internal.
There are 5 Access modifiers in total.
Public, private, protected, internal, protected internal
1. default access modifier for elements in the namespace
According to the above red error message, we can know that only two access modifiers public and internal can be used in the namespace. If no access modifier is displayed for these elements, the modifier is internal by default.
Public: Any other code of the same assembly or other assembly that references the Assembly can access this type or member.
Internal: Any code in the same assembly can access this type or member, but other assembly cannot.
2. default access modifiers for members of various types
The remaining modifiers are mainly inherited from this language. The inherited types include class and interface ). Public and internal can also be used for type members.
Private: Code of the same class and structure can access this type and members.
Protected: code in the same class and derived (inherited feature) class can access this type and member.
Protected internal: Any code in the same assembly or any derived class in other assembly can access this type or member.
MSDN prompt:
1) The accessibility of a derived class cannot be higher than its base type. In other words, there cannot be A public class B Derived from internal Class. If this is allowed, A will become A public class, because all protected members or internal members of A can be accessed from the derived class.
2) The accessibility of a member must not be higher than that of its contained type.
3) You can declare class members (including Nested classes and structures) using any of the five access types ).
Interface)
The default access modifier for interface members is public, and the access modifier cannot be displayed.
Class)
The default constructor is a public access modifier.
The Destructor cannot display the access modifier and is a private access modifier by default.
The default access modifier for class members is private;
Enumeration (enum)
By default, enumeration type members are public access modifiers and cannot be displayed with modifiers.
Structure (struct)
The structure member is a private Modifier by default.
The structure member cannot be declared as a protected member because the structure does not support inheritance.
Nested type
The default access modifier of the nested type is private. It is consistent with the default access type of the class and structure members.