ListEnumerator Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
The ListEnumerator class lets you traverse the elements in a list.
public ref class ListEnumerator : Microsoft::Dynamics::Ax::Xpp::XppObjectBase, Microsoft::Dynamics::Ax::Xpp::Enumerator
public class ListEnumerator : Microsoft.Dynamics.Ax.Xpp.XppObjectBase, Microsoft.Dynamics.Ax.Xpp.Enumerator
type ListEnumerator = class
inherit XppObjectBase
interface Enumerator
Public Class ListEnumerator
Inherits XppObjectBase
Implements Enumerator
- Inheritance
- Implements
Remarks
List enumerators start before the first element in the list. You must call the ListEnumerator.moveNext method to make it point to the first element in the list. It is best practice to use the ListEnumerator class instead of the ListIterator class, because enumerators are automatically created on the same tier as the list (when the list.getEnumerator method is called). This avoids a potential problem in code that is marked as Called from, where the iterator and list can be on separate tiers. In addition, list enumerators require less code than list iterators and therefore perform slightly better. The only situation where you have to use a list iterator is if you want to delete items from a list (use the ListIterator.delete method).
The following example creates a list of integers and puts some values into it. It then creates an enumerator, and then sets the enumerator to the first element in the list and then the second element in the list.
{
List list = new List(Types::Integer);
ListEnumerator enumerator;
// Add some elements to the list
list.addEnd(1);
list.addEnd(2);
list.addStart(3);
// Set the enumerator
enumerator = list.getEnumerator();
// Print a description of the list
print enumerator.definitionString();
// Go to beginning of enumerator
enumerator.reset();
//Go to the first element in the List
enumerator.moveNext();
// Print contents of first and second elements
// First element is 3 as this was added to start of list
print enumerator.toString();
enumerator.moveNext();
print enumerator.toString();
pause;
}
Constructors
ListEnumerator() |
Fields
kernelClass | (Inherited from XppObjectBase) |
Properties
AxClassId |