MultiValueDictionary<TKey, TValue>.Enumerator Struct
Definition
Enumerates the key-value-list pairs in a MultiValueDictionary<TKey, TValue>.
public struct MultiValueDictionary<TKey, TValue>.Enumerator : IEnumerator<KeyValuePair<TKey, IReadOnlyList<TValue>>>, IEnumerator, IDisposable
- Implements
- Inherited Members
- Extension Methods
Remarks
Use the foreach statement to enumerate the dictionary rather than using this struct directly.
The enumerator provides read-only access. Modifying the underlying dictionary after enumeration begins invalidates the enumerator and causes MoveNext() or Reset() to throw InvalidOperationException.
Properties
Current
Gets the key-value-list pair at the current position of the enumerator.
public readonly KeyValuePair<TKey, IReadOnlyList<TValue>> Current { get; }
Property Value
- KeyValuePair<TKey, IReadOnlyList<TValue>>
The key-value-list pair at the current enumerator position.
Exceptions
- InvalidOperationException
Thrown when the enumerator is not positioned on an element.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
MoveNext()
Advances the enumerator to the next key-value-list pair.
public bool MoveNext()
Returns
Exceptions
- InvalidOperationException
Thrown when the dictionary was modified after the enumerator was created.
Reset()
Sets the enumerator to its initial position.
public void Reset()
Exceptions
- InvalidOperationException
Thrown when the dictionary was modified after the enumerator was created.
Explicit Interface Implementations
IEnumerator.Current
Gets the element in the collection at the current position of the enumerator.
readonly object IEnumerator.Current { get; }
Returns
- object
The element in the collection at the current position of the enumerator.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |