SequencedDictionary<TKey, TValue>.DictionaryEnumerator Struct
Definition
Enumerates the elements of a SequencedDictionary<TKey, TValue> as DictionaryEntry values.
public struct SequencedDictionary<TKey, TValue>.DictionaryEnumerator : IDictionaryEnumerator, IEnumerator
- Implements
- Inherited Members
- Extension Methods
Remarks
Use the foreach statement to simplify the enumeration process instead of directly using this enumerator.
The enumerator provides read-only access to the dictionary's elements. Modifying the underlying dictionary while enumerating invalidates the enumerator.
Constructors
DictionaryEnumerator(SequencedDictionary<TKey, TValue>)
Initializes a new instance of the SequencedDictionary<TKey, TValue>.DictionaryEnumerator struct.
public DictionaryEnumerator(SequencedDictionary<TKey, TValue> dictionary)
Parameters
dictionarySequencedDictionary<TKey, TValue>The dictionary to enumerate. Must not be null.
Exceptions
- ArgumentNullException
dictionaryis null.
Properties
Current
Gets the element in the collection at the current position of the enumerator.
public readonly object Current { get; }
Property Value
- object
The element in the collection at the current position of the enumerator.
Entry
Gets both the key and the value of the current dictionary entry.
public readonly DictionaryEntry Entry { get; }
Property Value
- DictionaryEntry
A DictionaryEntry containing both the key and the value of the current dictionary entry.
Exceptions
- InvalidOperationException
The IDictionaryEnumerator is positioned before the first entry of the dictionary or after the last entry.
Key
Gets the key of the current dictionary entry.
public readonly object Key { get; }
Property Value
- object
The key of the current element of the enumeration.
Exceptions
- InvalidOperationException
The IDictionaryEnumerator is positioned before the first entry of the dictionary or after the last entry.
Value
Gets the value of the current dictionary entry.
public readonly object? Value { get; }
Property Value
- object
The value of the current element of the enumeration.
Exceptions
- InvalidOperationException
The IDictionaryEnumerator is positioned before the first entry of the dictionary or after the last entry.
Methods
MoveNext()
Advances the enumerator to the next element of the collection.
public bool MoveNext()
Returns
- bool
true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
Exceptions
- InvalidOperationException
The collection was modified after the enumerator was created.
Reset()
Sets the enumerator to its initial position, which is before the first element in the collection.
public void Reset()
Remarks
Restarts enumeration by taking a fresh enumerator (and therefore a fresh version snapshot) from the dictionary.
Exceptions
- InvalidOperationException
The collection was modified after the enumerator was created.
- NotSupportedException
The enumerator does not support being reset.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |