Accessibility

When access is allowed to a class or its members, that class or member is said to be accessible. Accessibility is typically controlled through the use of the PUBLIC, PROTECTED, PRIVATE, INTERNAL, and PROTECTED INTERNAL modifiers in a class or member declaration.

We recommend that you use private or protected access for greater maintainability. Classes, methods, and properties are private by default, unless designated otherwise.

The types used in the signature of any member must be as accessible as the member itself. For example, you cannot have a parameter declaration or return type with private accessibility in a publicly accessible method.

You can change the accessibility of nonvirtual members in an inherited class. This means that you can specify any valid accessibility for a nonvirtual member within the inheriting class, regardless of the accessibility of the corresponding member in the parent class. For example, field classA.fred might be private, but if classB extends classA, you can define classB.fred as public.

When you .INCLUDE from a repository and specify the PUBLIC modifier, all fields are marked public. The default states for namespace members, class members, and structure members are as follows:

Member

Default access state

Namespace

PUBLIC

Class

PRIVATE

Structure (in a structure that is not declared in a routine)

PUBLIC