Monday, 18 August 2014

List

A List object contains members that are accessed sequentially. Lists are
structures that can contain members of any X++ type. All the members in the
same list must be of the same type.


static void List(Args _args)
{
    List integerList = new List(Types::String);
    ListEnumerator enumerator;
 
 
    // Add some elements to the list
    integerList.addEnd("a");
    integerList.addEnd("b");
    integerList.addStart("c");
     
 
    // Set the enumerator
    enumerator = integerList.getEnumerator();
 
 
    // Go to beginning of enumerator
    enumerator.reset();
 
 
    //Go to the first element in the List
    enumerator.moveNext();
 
 
    // Print contents of first and second elements
    info(strfmt("First element is %1", enumerator.current()));
    enumerator.moveNext();
    info(strfmt("Second element is %1", enumerator.current()));
 
 
    //Print no of elements in the List
    info(strFmt('No of element is %1',integerList.elements()));

 
    //Print type of elements
    info(strFmt('Type of element is %1',integerList.typeId()));
}

No comments:

Post a Comment