Table of Contents

ToDictionary Method

Definition

Namespace
Cuemon.Extensions.Collections.Generic
Assemblies
Cuemon.Extensions.Collections.Generic.dll
Source
src/Cuemon.Extensions.Collections.Generic/EnumerableExtensions.cs

ToDictionary<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>)

Creates a Dictionary<TKey, TValue> from the specified source sequence.

public static IDictionary<TKey, TValue> ToDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> source)

Parameters

source IEnumerable<KeyValuePair<TKey, TValue>>

An IEnumerable<T> to extend.

Returns

IDictionary<TKey, TValue>

A Dictionary<TKey, TValue> that is equivalent to the specified source sequence.

Type Parameters

TKey

The type of keys in the source.

TValue

The type of values in the source.

Exceptions

ArgumentNullException

source is null.

ArgumentException

source contains at least one KeyValuePair<TKey, TValue> that produces duplicate keys for two elements.

ToDictionary<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>, IEqualityComparer<TKey>)

Creates a Dictionary<TKey, TValue> from the specified source sequence.

public static IDictionary<TKey, TValue> ToDictionary<TKey, TValue>(this IEnumerable<KeyValuePair<TKey, TValue>> source, IEqualityComparer<TKey> comparer)

Parameters

source IEnumerable<KeyValuePair<TKey, TValue>>

An IEnumerable<T> to extend.

comparer IEqualityComparer<TKey>

The IEqualityComparer<T> implementation to use when comparing keys.

Returns

IDictionary<TKey, TValue>

A Dictionary<TKey, TValue> that is equivalent to the specified source sequence.

Type Parameters

TKey

The type of keys in the source.

TValue

The type of values in the source.

Exceptions

ArgumentNullException

source is null - or - comparer is null.

ArgumentException

source contains at least one KeyValuePair<TKey, TValue> that produces duplicate keys for two elements.