Multiset<T>.Enumerator Struct
Definition
Enumerates the elements of a Multiset<T>, yielding each element as many times as its occurrence count in an unspecified order.
public struct Multiset<T>.Enumerator : IEnumerator<T>, IEnumerator, IDisposable
- Implements
-
IEnumerator<T>
- Inherited Members
- Extension Methods
Remarks
Use the foreach statement to enumerate the multiset rather than using this struct directly.
The enumerator provides read-only access. Modifying the underlying multiset after enumeration begins invalidates the enumerator and causes MoveNext() or Reset() to throw InvalidOperationException.
Properties
Current
Gets the element at the current position of the enumerator.
public readonly T Current { get; }
Property Value
- T
The element in the multiset at the current enumerator position.
Exceptions
- InvalidOperationException
The enumerator is positioned before the first element or after the last 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 element in the multiset.
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 multiset was modified after the enumerator was created.
Reset()
Sets the enumerator to its initial position, before the first element in the multiset.
public void Reset()
Exceptions
- InvalidOperationException
The multiset 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 |