System.Collections.IEnumerator
Added in .NET 1.1
supports a simple iteration over a non-generic collection
This allows you to implement a non-standard way of enumerating something, ie returning its elements one-by-one
public interface IEnumerator
{
object Current { get; }
bool MoveNext();
void Reset();
}
Current - (Property) Throws an exception if MoveNext returns false
MoveNext - (Method) sets Current to the next element. If MoveNext passes the end of the collection, the enumerator is positioned after the last element and MoveNext returns false
Reset - (Method) Sets the enumerator before the first element
Collections do not usually implement enumerators
Collections usually provide enumerators via the IEnumerable interface
© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext