Microsoft Dynamics AX 2012 R3 Development-2 Locus IT Services

Microsoft Dynamics AX 2012 R3 Development-2

Locus IT ServicesMicrosoft Dynamics AX 2012 R3 Development-2

Lesson 7 – Referencing Object Methods

Referencing Object Methods:

In an X++ method, the keyword this is a reference to the instance of the class or table in which the this keyword is used. The this reference is never required, but it can clarify your code, and it enhances the behavior of IntelliSense in the code editor.

The this reference can be used in the following ways:

  • Can be used to qualify the names of other instance (non-static) methods in the same class where the this reference is used
  • Can be used to quality the names of methods that are inherited by the this object
  • Can be used to qualify the names of fields on the table that contains the method that the this keyword is used in

The this reference cannot be used in the following ways:

  • Cannot be used to qualify the names of member variables that are declared in the classDeclaration code.
    C# allows such qualification.
  • Cannot be used in a static method.
  • Cannot be used to qualify the names of static methods of the class or table.

Methods in X++

The following blocks of code are standard for X++ application classes:

Code block type Description
classDescription declaration block Contains class modifiers such as public, private, and extends.

Also contains the field members for objects that are constructed from this class. IntelliSense can display a list of the members when you type the X++ keyword this.

new method The constructor. This method can be called only by using the new keyword. The syntax is typically similar to:
myClassInstance = new MyClass();

Derived classes can call the new method of their constructor by calling super method reference.

finalize method The destructor method.

However, in X++ this is a destructor only by convention. The finalize method is not called automatically by the system during garbage collection.

Additional methods for a class fall into the following types:

  • Instance methods
  • Static methods
  • Main methods
Locus IT Project Management Office
What’s it?