संपादित करें

इसके माध्यम से साझा किया गया


IEnumerator<T>.Current Property

Definition

Gets the element in the collection at the current position of the enumerator.

public:
 property T Current { T get(); };
public T Current { get; }
member this.Current : 'T
Public ReadOnly Property Current As T

Property Value

T

The element in the collection at the current position of the enumerator.

Remarks

Current is undefined under any of the following conditions:

  • The enumerator is positioned before the first element in the collection, immediately after the enumerator is created. MoveNext must be called to advance the enumerator to the first element of the collection before reading the value of Current.

  • The last call to MoveNext returned false, which indicates the end of the collection.

  • The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements.

Current returns the same object until MoveNext is called. MoveNext sets Current to the next element.

Notes to Implementers

Implementing this interface requires implementing the nongeneric IEnumerator interface. The Current property appears on both interfaces, and has different return types. Implement the nongeneric Current property as an explicit interface implementation. This allows any consumer of the nongeneric interface to consume the generic interface.

Applies to

See also