Skip to content

Latest commit

 

History

History
7 lines (4 loc) · 1.36 KB

ii.8.1-visibility-of-top-level-types-and-accessibility-of-nested-types.md

File metadata and controls

7 lines (4 loc) · 1.36 KB

II.8.1 Visibility of top-level types and accessibility of nested types

Visibility is attached only to top-level types, and there are only two possibilities: visible to types within the same assembly, or visible to types regardless of assembly. For nested types (i.e., types that are members of another type) the nested type has an accessibility that further refines the set of methods that can reference the type. A nested type can have any of the seven accessibility modes (see Partition I), but has no direct visibility attribute of its own, using the visibility of its enclosing type instead.

Because the visibility of a top-level type controls the visibility of the names of all of its members, a nested type cannot be more visible than the type in which it is nested. That is, if the enclosing type is visible only within an assembly then a nested type with public accessibility is still only available within that assembly. By contrast, a nested type that has assembly accessibility is restricted to use within the assembly even if the enclosing type is visible outside the assembly.

To make the encoding of all types consistent and compact, the visibility of a top-level type and the accessibility of a nested type are encoded using the same mechanism in the logical model of §II.23.1.15.