Methods in X++
When you declare a class, the following standard methods are created:
classDeclaration: opens automatically when you double-click the class.
new: the default constructor method.
finalize: the destructor method.
Additional methods for a class fall into the following types:
You can create methods on tables in addition to creating them on classes.
Static methods, or class methods, belong to a class and are created by using the keyword static. They are called by using the following syntax:
You do not need to instantiate an object before you use static methods. Static methods are widely used in Microsoft Dynamics AX to work with data that is stored in tables.
It is not possible to use member variables in a static method.
For more information, see Static Methods.
A main method is a class method that is executed directly from a menu option.
static void main (Args _args)
The method should only create an instance of the object and then call the necessary member methods. The _args parameter allows you to transfer data to the method.
For more information, see Activating a class from a menu item.