IEnumerator<T>.Current IEnumerator<T>.Current IEnumerator<T>.Current IEnumerator<T>.Current Property

定义

获取集合中位于枚举数当前位置的元素。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

属性值

T T T T

集合中位于枚举数当前位置的元素。The element in the collection at the current position of the enumerator.

注解

Current 未定义任何以下情况下: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 必须调用以枚举器前进到集合,然后再读取的值的第一个元素CurrentMoveNext must be called to advance the enumerator to the first element of the collection before reading the value of Current.

  • 上次调用MoveNext返回false,指示集合的末尾。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 之前,MoveNext 返回相同的对象。Current returns the same object until MoveNext is called. MoveNextCurrent 设置为下一个元素。MoveNext sets Current to the next element.

实施者说明

实现此接口要求实现非泛型IEnumerator接口。Implementing this interface requires implementing the nongeneric IEnumerator interface. Current属性组显示在这两个接口,并且具有不同的返回类型。The Current property appears on both interfaces, and has different return types. 实现非泛型Current作为显式接口实现的属性。Implement the nongeneric Current property as an explicit interface implementation. 这允许在非泛型接口的任何使用者使用泛型接口。This allows any consumer of the nongeneric interface to consume the generic interface.

适用于

另请参阅