Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 17314

Little bit taste of List In Dynamics Ax 2012

$
0
0

In Dynamics Ax List is used as collection, You can add , remove or update elements in it. Type of list is define at the time of its declaration and cannot be change after initialization.

We can iterate in List with the help of ListIterator object, which have several methods to process on list.

 List           intList       = new List(Types::Integer);
    List           strList = new List(Types::String);
    ListIterator   literator  

    // add the element at the end of the list
    intList.addEnd(123); 

    // add the element at the start of the list
    intList.addStart(321); 

    intList.addEnd(300); 

    strList.addEnd ("Raza");

    strList.addStart ("Ali"); 

    strList.addStart ("Zaidi"); 

    // 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(strList);
    while (literator.more())
    {
        // can provide some condition, i.e. if check etc
        if (literator.value() == "Ali")
        {
            listIterator.insert ("Between Raza and Zaidi");
        }
    }

Viewing all articles
Browse latest Browse all 17314


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>