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


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

 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 the MoveNext method 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. 如果对集合所做的更改(如添加、修改或删除元素),则枚举器将失效且不可恢复,并且对或的下一个调用将 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.