Editare

Partajați prin


AceEnumerator.IEnumerator.Current Property

Definition

Gets the current element in the collection.

property System::Object ^ System::Collections::IEnumerator::Current { System::Object ^ get(); };
object System.Collections.IEnumerator.Current { get; }
member this.System.Collections.IEnumerator.Current : obj
 ReadOnly Property Current As Object Implements IEnumerator.Current

Property Value

The current element in the collection.

Implements

Exceptions

The collection was modified after the enumerator was created.

Remarks

After an enumerator is created or after a call to the Reset method, you must call the MoveNext method to advance the enumerator to the first element of the collection before reading the value of IEnumerator.Current; otherwise, IEnumerator.Current is undefined.

IEnumerator.Current also throws an exception if the last call to MoveNext returned false, which indicates the end of the collection.

IEnumerator.Current does not move the position of the enumerator, and consecutive calls to IEnumerator.Current return the same object until either MoveNext or Reset is called.

An enumerator remains valid as long as the collection remains unchanged. If changes, such as adding, modifying, or deleting elements, are made to the collection, the enumerator is irrecoverably invalidated, and the next call to MoveNext or Reset throws an InvalidOperationException. If the collection is modified between MoveNext and IEnumerator.Current, IEnumerator.Current returns the element that it is set to, even if the enumerator is already invalidated.

Applies to