WeekPattern.Enumerator Struct
Definition
Enumerates the selected days of a WeekPattern in Sunday-first order without allocating.
public struct WeekPattern.Enumerator : IEnumerator<DayOfWeek>, IEnumerator, IDisposable
- Implements
- Inherited Members
- Extension Methods
Remarks
Returned by GetEnumerator() and bound directly by the C# foreach pattern, so
iterating a WeekPattern requires no heap allocation. Accessing the enumerator through
IEnumerator<T> or IEnumerator boxes this struct as a one-off cost.
The enumerator captures the underlying bitmask at construction; the source WeekPattern is a value type and immutable, so the snapshot semantics are exact.
Properties
Current
Gets the DayOfWeek at the current position of the enumerator.
public readonly DayOfWeek Current { get; }
Property Value
- DayOfWeek
The day yielded by the most recent successful MoveNext() call.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public readonly void Dispose()
MoveNext()
Advances the enumerator to the next selected day.
public bool MoveNext()
Returns
Reset()
Resets the enumerator to its initial position, before the first selected day.
public void Reset()
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 |