Home   Cover Cover Cover Cover
 

Access modifiers

Question: Place the access modifiers public, private, internal and protected in order according to their strictness.

Answer:

private
strictest: only visible in the declaring class.


protected
Visible in the declaring class and in all its subclasses, even if these classes belong to different namespaces. Not visible in non-subclasses in the same namespace or in other namespaces.


internal
Like public, but the visibility is restricted to namespaces that belong to the same assembly.


public
most general: visible everywhere in the declaring namespace as well as in other namespaces that import the declaring namespace.