Mono Class Library: System.Collections.IEnumerator Overview | Members

System.Collections.IEnumerator.Current Property

Gets the element in the collection over which the current instance is positioned. [Edit]

public object Current { get; }

Value

The element in the collection over which the current instance is positioned. [Edit]

Exceptions

TypeReason
InvalidOperationException

The current instance is positioned before the first element or after the last element of the collection.

The collection was modified after the current instance was instantiated.

[Edit]

Remarks

Note: When the current instance is constructed or after IEnumerator.Reset is called, use IEnumerator.MoveNext to position the current instance over the first element of the collection.

Operation

It is required that IEnumerator.Current return the element in the collection over which the current instance is positioned unless it is positioned before the first or after the last element of the collection. If the current instance is positioned before the first element or after the last element of the collection, IEnumerator.Current returns an unspecified value or throws an unspecified exception. If elements were added, removed, or repositioned in the collection after the current instance was instantiated, IEnumerator.Current returns the value it would have returned before the collection was modified.

It is also required that IEnumerator.Current not change the position of the current instance: consecutive calls to IEnumerator.Current are required to return the same object until either IEnumerator.MoveNext or IEnumerator.Reset is called.

This property is read-only.

Usage
Use IEnumerator.Current to get the element in the collection over which the current instance is positioned, provided that the current instance is not positioned before the first element or after the last element of the collection.

[Edit]

Requirements

Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0