HashSet<T>.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 ();
abstract member System.Collections.IEnumerator.Reset : unit -> unit
override this.System.Collections.IEnumerator.Reset : unit -> unit
Sub Reset () Implements IEnumerator.Reset
实现
例外
集合在枚举器创建后被修改。The collection was modified after the enumerator was created.
注解
调用后 IEnumerator.Reset ,必须调用方法, MoveNext 将枚举数前移到集合的第一个元素,然后再读取属性的值 Current 。After calling IEnumerator.Reset, 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. 如果对集合所做的更改(如添加、修改或删除元素),则枚举器将失效且不可恢复,并且对或的下一个调用将 MoveNext IEnumerator.Reset 引发 InvalidOperationException 。If 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.