Wednesday 18 December 2013

Static Methods,Main Methods Instance Methods in ax 2012


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:
ClassName::methodName();
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.
NoteNote
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)
 
{
 
    // Your X++ code here.
 
}
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.


No comments:

Post a Comment