Table of Contents

EvictingDictionary<TKey, TValue>.DictionaryEnumerator Struct

Definition

Namespace
Bodu.Collections.Generic
Assembly
Bodu.Collections.dll
Package
Bodu.Collections 1.0.0
Source
EvictingDictionary{T,T}.DictionaryEnumerator.cs

Enumerates the elements of an EvictingDictionary<TKey, TValue>.

public struct EvictingDictionary<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(EvictingDictionary<TKey, TValue>)

Initializes a new instance of the EvictingDictionary<TKey, TValue>.DictionaryEnumerator struct.

public DictionaryEnumerator(EvictingDictionary<TKey, TValue> dictionary)

Parameters

dictionary EvictingDictionary<TKey, TValue>

The dictionary to enumerate. Must not be null.

Exceptions

ArgumentNullException

dictionary is 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 and clock 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

ProductVersions
.NET8, 10