BCL mscorlib [00 00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 ] 1.0.5000.0 2.0.0.0 4.0.0.0 System.Runtime.InteropServices.ComVisible(true) System.Runtime.InteropServices.Guid("496B0ABE-CDEE-11d3-88E8-00902754C43A")

is the base interface for all non-generic collections that can be enumerated. For the generic version of this interface see . contains a single method, , which returns an . provides the ability to iterate through the collection by exposing a property and and methods.

It is a best practice to implement and on your collection classes to enable the foreach (For Each in Visual Basic) syntax, however implementing is not required. If your collection does not implement , you must still follow the iterator pattern to support this syntax by providing a GetEnumerator method that returns an interface, class or struct. When using Visual Basic, you must provide an implementation, which is returned by GetEnumerator. When developing with C# you must provide a class that contains a Current property, and MoveNext and Reset methods as described by , but the class does not have to implement .

Exposes an enumerator, which supports a simple iteration over a non-generic collection.

- Method
  1.0.5000.0
  2.0.0.0
  4.0.0.0
  System.Runtime.InteropServices.DispId(-4)
  System.Collections.IEnumerator

  The foreach statement of the C# language (For Each in Visual Basic) hides the complexity of the enumerators. Therefore, using foreach is recommended, instead of directly manipulating the enumerator.

  Enumerators can be used to read the data in the collection, but they 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, the property is undefined. Therefore, you must call the method to advance the enumerator to the first element of the collection before reading the value of .

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

  If passes the end of the collection, the enumerator is positioned after the last element in the collection and returns false. When the enumerator is at this position, subsequent calls to also return false. If the last call to returns false, is undefined. To set to the first element of the collection again, you can call followed by .

  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 its behavior is undefined.

  The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.

  Returns an enumerator that iterates through a collection.

  An object that can be used to iterate through the collection.

  0
0