ListEnumerator.Reset Method

Definition

Moves the enumerator to the start of the list.

public:
 virtual void Reset();
public void Reset ();
abstract member Reset : unit -> unit
override this.Reset : unit -> unit
Public Sub Reset ()

Implements

Remarks

The reset method moves the enumerator to the start of the list, 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.

The following example creates a list and then an enumerator for the list. It uses the reset method to move to the start of the list and then uses the moveNext method to move to the first 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(); 
    // Go to beginning of enumerator 
    enumerator.reset(); 
    //Go to the first element in the List 
    enumerator.moveNext(); 
    // First element is 3 as this was added to start of list 
    print enumerator.toString(); 
    pause; 
}

Applies to