Reference from default visibility for C # classes and Members (fields, methods, etc)?
Classes and structs that is declared directly within a namespace (in other words, that is not nested within other Classe s or structs) can be either public or internal. Internal is the default if no access modifier is specified.
Classes and structs that are directly declared under namespaces are internal by default.
The access level for class members and structs members, including nested classes and structs, are private by default.
Members of classes and structs, including embedded classes and structs, are private by default
Interfaces default to internal access.
The interface is internal by default
Delegates behave like classes and structs. By default, they has internal access when declared directly within a namespace, and private access when nested.
Delegates are similar to classes and structs. Directly declaring access rights under a namespace is internal by default. If it's embedded, it's private.
Top-level types, which is not nested in other types, can only has internal or public accessibility. The default accessibility for these types is internal.
Summary, the highest level of type (not embedded in other types), can only have internal and public access rights. The default access permissions for these types are internal
For embedded types, however,
And for nested types:
Members of the Default member accessibility
---------- ----------------------------
The members of the enum public//enum are public access rights
class private//member, default is private access rights
Interface public//member of interface, default is private access rights
struct private//struct member, similar to class, the default access rights are also private
Default modifiers in C #