Table of Contents

MultiValueBacking Enum

Definition

Namespace
Bodu.Collections.Generic
Assembly
Bodu.Collections.dll
Package
Bodu.Collections 1.0.0
Source
MultiValueBacking.cs

Specifies how a MultiValueDictionary<TKey, TValue> stores the values associated with each key.

public enum MultiValueBacking
Extension Methods

Fields

List = 0

Values for a key are kept in insertion order and per-key duplicates are allowed. This is the default and preserves the historical behavior of MultiValueDictionary<TKey, TValue>.

Set = 1

Values for a key are deduplicated using the dictionary's ValueComparer; adding a value already associated with the key leaves the dictionary unchanged. The insertion order of each value's first occurrence is preserved.

Remarks

The backing is selected at construction time and is immutable for the lifetime of the dictionary. It is reported by Backing.

List corresponds to a list multimap: every added value is retained, including per-key duplicates. Set corresponds to an order-preserving set multimap: values are deduplicated per key using the dictionary's ValueComparer, and the insertion order of each value's first occurrence is preserved.

Under Set, each add performs a linear scan of the key's existing values to detect duplicates. This trade-off keeps the per-key values in insertion order and preserves the IReadOnlyList<T> view contract exposed by the dictionary.

Applies to

ProductVersions
.NET8, 10