Understanding Accessor Keywords in X++ Programming Language - D365 F&O Guide
Table of Content:
Accessor keywords can be used to control whether the methods in other classes can call the methods in your class. Class inheritance is also affected by the following accessor keywords.
-
public
- Methods declared aspublic
can be called from anywhere that the class is accessible. Apublic
method can be overridden by a subclass, unless that method is declared asfinal
. -
protected
- Methods declared asprotected
can only be called from methods in the same class or methods in a subclass of that class. Aprotected
method can still be overridden in a subclass. -
private
- Methods declared asprivate
can only be called from methods within the same class. Unlikepublic
andprotected
methods,private
methods can't be overridden in a subclass.