Given the current Enumeration
implementation in Java, you should implement the IEnumerator<T>
class, which is the class that enumerates over a collection and provides the methods better fitted to the Java counterpart.
MoveNext
for example returns bool
whether there actually is a next value in the enumeration, and relates to the hasMoreElements
method of Java's Enumeration
.
The IEnumerable<T>
interface does not expose any of the details regarding the current state of the enumeration, like Current
or MoveNext
; it only exposes a GetEnumerator
method that returns an IEnumerator<T>
implementation for the given IEnumerable<T>
.
Hence, it is the IEnumerator<T>
class the one that exposes how to iterate over the collection, the current element, and whether there are more, similar to the Enumeration
interface in Java.