Information Technology Reference
In-Depth Information
Declaring an IEnumerator Enumerator
To create a non-generic interface enumerator class, you must declare a class that implements
the IEnumerator interface. The IEnumerator interface
Is a member of the System.Collections namespace
￿
Contains the three members Current , MoveNext , and Reset
￿
The following code shows the outline of a non-generic enumerator class. It does not show
how the position is maintained. Notice that Current returns a reference to an object .
using System.Collections; // Include the namespace.
class MyEnumerator: IEnumerator
{
public object Current { get; } // Current
public bool MoveNext() { ... } // MoveNext
public void Reset() { ... } // Reset
...
}
Search WWH ::




Custom Search