mscorlib 2.0.0.0 4.0.0.0 System.Object System.Collections.IEnumerator System.Runtime.InteropServices.ComVisible(true)

Enumerators allow only reading the data in the collection. Enumerators cannot be used to modify the underlying collection.

Initially, the enumerator is positioned before the first element in the collection. The method also brings the enumerator back to this position. At this position, calling the property throws an exception. Therefore, you must call the method to advance the enumerator to the first element of the collection before reading the value of the property.

returns the same object until either or is called. sets to the next element.

After the end of the collection is passed, the enumerator is positioned after the last element in the collection, and calling returns false. If the last call to returned false, calling throws an exception. To reset to the first element of the collection, call followed by a call to .

An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between calling and , returns the element to which it is currently set, even if the enumerator is already invalidated.

The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.

Represents the enumerator for objects in a .

- Property
  2.0.0.0
  4.0.0.0
  System.Security.Permissions.KeyContainerPermissionAccessEntry To be added.

  When the enumerator is created, it does not point to an object, so the property is not valid and will throw an exception if it is accessed. You must first call the method to position the cursor at the first object in the collection.

  Getting the property multiple times with no intervening calls to will return the same object each time.

  Gets the current entry in the collection.

- Method
  2.0.0.0
  4.0.0.0
  System.Boolean

  The method returns false immediately if there are no objects in the collection.

  returns true until it has reached the end of the collection. It then returns false for each successive call. However, once has returned false, accessing the property throws an exception.

  Upon creation, an enumerator is positioned before the first object in the collection, and the first call to positions the enumerator to the first object in the collection.

  Moves to the next element in the collection.

  true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.

- Method
  2.0.0.0
  4.0.0.0
  System.Void

  An enumerator moves in a forward-only direction. Use this method to return to the beginning of the collection.

  The method positions the cursor at the first object in the collection. After calling , you do not need to call to move the cursor forward to the first object.

  Resets the enumerator to the beginning of the collection.

- Property
  2.0.0.0
  4.0.0.0
  System.Object To be added.

  Do not call this method; use the property instead.

  Gets the current object in the collection.