Dec 2, 2013

List in AX

List is the structure which contain values of any same type, where we can access sequentially.

static void testList(Args _args)
{
List li = new List(Types::Integer);
ListEnumerator enumerator;
ListIterator lItr;
;
// Add some elements to the list
li.addStart(3);
li.addEnd(1);
li.addEnd(2);

info(strfmt("%1", li.definitionString())); // returns the "Type" of the list
info(strfmt("%1", li.toString())); // output --> <3,1,2>

enumerator = li.getEnumerator();
while(enumerator.moveNext())
{
info(Strfmt("Enumerator %1 ",enumerator.current()));
}

lItr = new ListIterator (li);
while(lItr.more()) // checks whether there are more elements in the list
{
info(strFmt("Iterator %1",lItr.value()));
lItr.next(); // Skips to the next element
}

}

No comments: