When implemented by a class, gets the current element in the collection.
[Visual Basic] ReadOnly Property Current As Object [C#] object Current {get;} [C++] Object* get_Current() = 0; [JScript] abstract function get Current() : Object;
The current element in the collection.
Exception Type | Condition |
---|---|
InvalidOperationException | The enumerator is positioned before the first element of the collection or after the last element.
-or- The collection was modified after the enumerator was instantiated. |
After an enumerator is created or after a Reset, MoveNext must be called to advance the enumerator to the first element of the collection before reading the value of Current. Otherwise, Current is undefined.
Current will also throw an exception if the last call to MoveNext returned false which indicates the end of the collection.
Current does not move the position of the enumerator and consecutive calls to Current will return the same object until either MoveNext or Reset is called.
IEnumerator Interface | IEnumerator Members | System.Collections Namespace | MoveNext | Reset