Variable Scopes [AX 2012]
Updated: August 6, 2011
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
A scope defines the area in which an item can be accessed:
Instance variables, declared in class declarations, can be accessed from any methods in the class, and from methods that extend the class.
Local variables can be accessed only in the block in which they were defined. All variables created by users have local scope.
A variable, a, is declared in the class and a variable, b, is declared in the aNewMethod method.
As the method is declared in the class block, it can access all variables defined in the class. The aNewMethod method has access to variable a.
Variable b is declared in the aNewMethod method block, so that it can be accessed only from within this block.