DbEnumerator.Current 属性

定义

获取集合中的当前元素。Gets the current element in the collection.

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

属性值

Object

集合中的当前元素。The current element in the collection.

实现

例外

枚举器位于集合中第一个元素之前或最后一个元素之后。The enumerator is positioned before the first element of the collection or after the last element.

注解

在创建枚举器之后或之后 ResetMoveNext 必须先调用以将枚举数前移到集合的第一个元素,然后才能读取的值 Current ; 否则, Current 将未定义。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 如果最后一次调用返回 false,则还会引发异常 MoveNext ,指示集合的末尾。Current also throws an exception if the last call to MoveNext returned false, which indicates the end of the collection. Current 在调用或之前,不会移动枚举器的位置和连续调用来 Current 返回相同的对象 MoveNext ResetCurrent does not move the position of the enumerator and consecutive calls to Current return the same object until either MoveNext or Reset is called. 只要集合保持不变,枚举器就仍有效。An enumerator remains valid as long as the collection remains unchanged. 如果对集合所做的更改(如添加、修改或删除元素),则枚举器将失效且不可恢复,并将对或的下一个调用 MoveNext Reset 生成 InvalidOperationExceptionIf changes are made to the collection, such as adding, modifying or deleting elements, the enumerator is irrecoverably invalidated and the next call to MoveNext or Reset generates an InvalidOperationException. 如果集合在和之间进行了修改 MoveNext Current ,则 Current 将返回它所设置到的元素,即使枚举器已失效。If the collection is modified between MoveNext and Current, Current returns the element to which it is set, even if the enumerator is already invalidated.

适用于