connect 2022 banner tablet connect 2022 banner mobile

AX 2012 Method -Accessor method

By Laura Lake | February 10, 2014

AX 2012 Method -Accessor method

For developers who are new to AX, and especially those coming from other products, the Accessor method, a type of AX 2012 Method,

may be a little confusing at first. You may be used to seeing the Get/Set keywords used like this…

{

    private string _mystring;

 

    public string mystring

    {

             get { return _mystring; }

             set {_mystring = somevalue;}

 

    }

}

AX 2012 Method 

In an AX 2012 Method, the same logic would be expressed in this way…

{

    str myString;

 

    publicstr myString(str _myString = myString)

    {

             myString = _myString;

             return myString;

    }

}

Get and Set happen here in the same method.

If the method is called with parameter_myString having a value, then the class variable (myString) is set to this value…

myString = _myString;

If the method is called without a parameter, the parameter defaults to the class variable…

(str _myString = myString)

Start the Conversation

It’s our mission to help clients win. We’d love to talk to you about the right business solutions to help you achieve your goals.

Subscribe To Our Blog

Sign up to get periodic updates on the latest posts.

Thank you for subscribing!

X