HashSet<T>.Enumerator.IEnumerator.Reset HashSet<T>.Enumerator.IEnumerator.Reset HashSet<T>.Enumerator.IEnumerator.Reset Method


設定列舉值至它的初始位置,這是在集合中第一個項目之前。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 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就會擲回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.