Monday, July 9, 2007

Declared Accessibility

  • Private
    The private modifier ensures that the method, field or attribute is visible only within the class it is defined.

  • Protected
    The protected modifier ensures that the method, field or attribute is visible within the class it is defined and also in the derived classes.

  • Public
    The public modifier declares the method, field or attributes to be visible to everyone.

  • Internal
    The internal keyword restricts the visibility of the member to just the specific files in the assembly in which the internal class is declared.

    For classes, an internal class and its members (public or not) are not visible to any programs that reference the assembly.

    For methods, fields and properties, using the internal keyword limits the visibility of that member to just the assembly. Thus, you can have a class visible to the outside world, but the class can contain methods, fields and properties that are visible only within the assembly.

  • Protected internal (meaning protected or internal)
    The intuitive meaning of protected internal is "access limited to this program or types derived from the containing class".

No comments: