SortedSet<T>.Enumerator.MoveNext 方法

定義

讓列舉程式前進至 SortedSet<T> 集合中的下一個項目。Advances the enumerator to the next element of the SortedSet<T> collection.

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 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. 如果對集合進行了變更,例如加入、修改或刪除專案,枚舉器會失效,且下一次呼叫 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.

適用於