Usage of Lists in AX:

Hi,
List is a type of data structure and collections, it can contain unlimited items, in x++, list can be created of several Types(specified in the Types base enum), the type must be specified on the declaration and it cannot be changed after the initialization.

There are some classes exists to enumerated and iterate the list object. ListIterator object has methods that can insert and deleted items from list, ListEnumeration cannot modify the list content.

Example:

List myList = new List(Types::Integer);
List myListString = new List(Types::String);
ListIterator literator

// add the element at the end of the list
myList.addEnd(2);

// add the element at the start of the list
myList.addStart(3);

myList.addEnd(7);

myListString.addEnd (“Second”);

myListString.addStart (“First”);

// If you want to insert the data at some specific index, then you need to make use of the listIterator class

// Iterator performs a midpoint

// insert at current position.

literator = new ListIterator(myListString);

while (literator.more())
{
// can provide some condition, i.e. if check etc
if (literator.value() == “First”)
{
listIterator.insert (“Between first and second”);
}
}

Advertisements

One thought on “Usage of Lists in AX:

  1. Aw, this was a really nice post. In concept I want to put in writing like this additionally – taking time and precise effort to make an excellent article… but what can I say… I procrastinate alot and not at all appear to get something done.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s