In Dynamics AX 4.0 when I would declare a class I would use the class = new class() assignment for instantiation. In Dynamics AX 2009, a construct method is used to in creating new instances of a classes and subclasses. When using a construct sometimes you will need to pass parameters into the construct to properly create the objects needed for development. Below I will provide an example of a construct using my favorite fashion item.

public static Purses construct(PurseType  PurseType)

{

Purses     purses;

;

switch (purseType)

{

case PurseType::LV :

purses = new LVBag ();

break;

case PurseType::Gucci :

purses = new GucciBag()

break;

case PurseType::Hermes :

purses = new HermesBag();

break;

case PurseType::Chanel :

purses = new ChanelBag ();

break;

}

return purses;

}

So I needed to pass in my enumeration to determine which class I would need to instantiate for use.


 

2,624

Sorry, the comment form is closed at this time.

Archives

Contact Information

Winfosoft Inc.

6864 Susquehanna Trail South

York, Pa. 17403

Phone : 717-428-1233

Fax : 717-326-1037

Email : info@winfosoft.com

Quick Contact

Countries We Serve

Our geographic focus in North America and the Caribbean with offices in Canada, United States and Trinidad and Tobago.