Dictionary<TKey,TValue>.ValueCollection.Enumerator.MoveNext 方法

定义

使枚举数前进到 Dictionary<TKey,TValue>.ValueCollection 的下一个元素。Advances the enumerator to the next element of the Dictionary<TKey,TValue>.ValueCollection.

public:
 virtual bool MoveNext();
public bool MoveNext ();
abstract member MoveNext : unit -> bool
override this.MoveNext : unit -> bool
Public Function MoveNext () As Boolean

返回

如果枚举数已成功地推进到下一个元素,则为 true;如果枚举数传递到集合的末尾,则为 falsetrue if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.

实现

异常

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

注解

创建枚举器后, 枚举数将定位在集合中的第一个元素之前, 第一次调用MoveNext会将枚举数前移到集合的第一个元素。After an enumerator is created, the enumerator is positioned before the first element in the collection, and the first call to MoveNext advances the enumerator to the first element of the collection.

如果MoveNext越过集合的末尾, 则枚举器将定位在集合中最后一个元素之后, 并MoveNext返回falseIf MoveNext passes the end of the collection, the enumerator is positioned after the last element in the collection and MoveNext returns false. 当枚举器位于此位置时, 对MoveNext的后续调用也将返回。 falseWhen the enumerator is at this position, subsequent calls to MoveNext also return false.

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

适用于

另请参阅