Share via


ListEnumerator Class

Definition

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
Microsoft.Dynamics.AX.KernelInterop.ProxyBase
ListEnumerator
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

Methods

__shouldCallNew(Type) (Inherited from XppObjectBase)
addXppProxyReference(Type, Object) (Inherited from XppObjectBase)
Call(String, Object[], Type[], Object[]) (Inherited from XppObjectBase)
cancelTimeOut(Int32) (Inherited from XppObjectBase)
createKernelClass(Object[], Type[], Object[]) (Inherited from XppObjectBase)
Current()

Retrieves the value that is pointed to by the enumerator.

Definitionstring()

Returns a description of the enumerator.

equal(XppObjectBase) (Inherited from XppObjectBase)
finalize() (Inherited from XppObjectBase)
GetIntPtr() (Inherited from XppObjectBase)
GetKernelInstanceUniqueId() (Inherited from XppObjectBase)
getTimeOutTimerHandle() (Inherited from XppObjectBase)
getXppProxyReference(Type) (Inherited from XppObjectBase)
handle()
IsManagedValid() (Inherited from XppObjectBase)
kernelhandle()
KernelInstanceDisposed() (Inherited from XppObjectBase)
MakeReflectionCall(String, Object[]) (Inherited from XppObjectBase)
Movenext()

Determines whether the enumerator denotes a valid list element.

newmethod() (Inherited from XppObjectBase)
notify() (Inherited from XppObjectBase)
notifyAll() (Inherited from XppObjectBase)
objectOnServer()
Obsolete.
(Inherited from XppObjectBase)
Reset()

Moves the enumerator to the start of the list.

setTimeOut(String, Int32)
Obsolete.
(Inherited from XppObjectBase)
setTimeOut(String, Int32, Boolean)
Obsolete.
(Inherited from XppObjectBase)
ToString()

Returns a description of the content of the element in the list that the enumerator is currently pointing to.

usageCount() (Inherited from XppObjectBase)
VerifyKernelClass() (Inherited from XppObjectBase)
wait() (Inherited from XppObjectBase)
Xml() (Inherited from XppObjectBase)
Xml(Int32) (Inherited from XppObjectBase)

Applies to