#712 – Accessibility Summary

Namespaces, types, class members, struct member, interface members and enumeration members all have an associated accessibility, dictated by the access modifer included in the member’s declaration.

The possible levels of accessibility are:

  • public – all code can access member
  • private – only code within the same type can access member
  • protected – code within type or subtype can access member
  • internal – code within the same assembly can access member
  • protected internal – code within the same assembly, within the same type, or within a subtype can access member

The type of member dictates which levels of accessibility are allowed:

  • class – can be public or internal  (default is internal)  [can only be public if parent class is public]
  • namespace – always public
  • class members – can be public, private, protected, internal or protected internal  (default is private)
  • struct members – can be public, private, or internal (default is private)
  • interface members – always public
  • enumeration members – always public
Advertisement