Dictionary<TKey,TValue>.ValueCollection.Enumerator.IEnumerator.Reset 方法

定义

将枚举数设置为其初始位置,该位置位于集合中第一个元素之前。Sets the enumerator to its initial position, which is before the first element in the collection.

 virtual void System.Collections.IEnumerator.Reset() = System::Collections::IEnumerator::Reset;
void IEnumerator.Reset ();
Sub Reset () Implements IEnumerator.Reset

实现

异常

集合在枚举器创建后被修改。The collection was modified after the enumerator was created.

注解

调用 IEnumerator.Reset 方法后,必须先调用 MoveNext 方法,以便将枚举器前进到集合的第一个元素,然后再读取 Current 属性的值。After calling the IEnumerator.Reset method, you must call the MoveNext method to advance the enumerator to the first element of the collection before reading the value of the Current property.

只要集合保持不变,枚举器就仍有效。An enumerator remains valid as long as the collection remains unchanged. 如果对集合所做的更改(如添加、修改或删除元素),则枚举器将失效且不可恢复,并且对 MoveNextIEnumerator.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 IEnumerator.Reset throws an InvalidOperationException.

适用于

另请参阅