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.
- Public access is most accessible. Access to the item is not restricted. The item can be accessed anywhere, inside or outside of the class.
- With protected access, only the containing class or its derived classes can access the item.
- Private access is least accessible. Access is restricted to the containing type, which means the item can only be accessed by other members within the same class. You can make changes without worrying about affecting other things.
- Internal access is limited to the current assembly. (Synergy .NET only)
- Protected internal access is limited to the current assembly and types derived from the containing class. (Synergy .NET only)
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.
In traditional Synergy, INTERNAL is the same as PUBLIC and is provided for portability to Synergy .NET. |
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 |