Dictionary<TKey,TValue>.Enumerator.IDictionaryEnumerator.Key 屬性

定義

取得位於列舉值目前位置之項目的索引鍵。

property System::Object ^ System::Collections::IDictionaryEnumerator::Key { System::Object ^ get(); };
object System.Collections.IDictionaryEnumerator.Key { get; }
member this.System.Collections.IDictionaryEnumerator.Key : obj
 ReadOnly Property Key As Object Implements IDictionaryEnumerator.Key

屬性值

位於字典中列舉值目前位置之項目的索引鍵。

實作

Key

例外狀況

列舉值是放在集合的第一個項目之前,或最後一個項目之後。

備註

IDictionaryEnumerator.Key 在下列任一情況下未定義:

  • 列舉值位於集合的第一個專案之前。 在建立列舉值或呼叫 方法之後 IEnumerator.Reset ,就會發生此情況。 MoveNext必須先呼叫 方法,才能將列舉值前進到集合的第一個專案,然後再讀取 屬性的值IDictionaryEnumerator.Key

  • 傳回false的最後一個呼叫 MoveNext ,表示集合的結尾,而且列舉值位於集合的最後一個元素之後。

  • 列舉值因為集合中所做的變更而失效,例如新增、修改或刪除專案。

IDictionaryEnumerator.Key 不會移動列舉值的位置,而且連續呼叫會 IDictionaryEnumerator.Key 傳回相同的物件,直到 MoveNext 呼叫 或 IEnumerator.Reset 為止。

適用於

另請參閱