Method ToDictionary
View SourceToDictionary<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>)
Creates a Dictionary<TKey, TValue> from a sequence of KeyValuePair<TKey, TValue> elements.
Declaration
[Obsolete("This method has been implemented by the framework.")]
public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>> source) where TKey : notnull
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<TKey, TValue>> | source | The source sequence of key-value pairs. |
Returns
Type | Description |
---|---|
Dictionary<TKey, TValue> | A Dictionary<TKey, TValue> containing the values mapped to their keys. |
Type Parameters
Name | Description |
---|---|
TKey | The type of the key. |
TValue | The type of the value. |
Remarks
This method executes immediately.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ToDictionary<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>>, IEqualityComparer<TKey>?)
Creates a Dictionary<TKey, TValue> from a sequence of KeyValuePair<TKey, TValue> elements. An additional parameter specifies a comparer for keys.
Declaration
[Obsolete("This method has been implemented by the framework.")]
public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(IEnumerable<KeyValuePair<TKey, TValue>> source, IEqualityComparer<TKey>? comparer) where TKey : notnull
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<KeyValuePair<TKey, TValue>> | source | The source sequence of key-value pairs. |
IEqualityComparer<TKey> | comparer | The comparer for keys. |
Returns
Type | Description |
---|---|
Dictionary<TKey, TValue> | A Dictionary<TKey, TValue> containing the values mapped to their keys. |
Type Parameters
Name | Description |
---|---|
TKey | The type of the key. |
TValue | The type of the value. |
Remarks
This method executes immediately.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ToDictionary<TKey, TValue>(IEnumerable<(TKey Key, TValue Value)>)
Creates a Dictionary<TKey, TValue> from a sequence of tuples of 2 where the first item is the key and the second the value.
Declaration
[Obsolete("This method has been implemented by the framework.")]
public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(IEnumerable<(TKey Key, TValue Value)> source) where TKey : notnull
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<(TKey Key, TValue Value)> | source | The source sequence of couples (tuple of 2). |
Returns
Type | Description |
---|---|
Dictionary<TKey, TValue> | A Dictionary<TKey, TValue> containing the values mapped to their keys. |
Type Parameters
Name | Description |
---|---|
TKey | The type of the key. |
TValue | The type of the value. |
Remarks
This method executes immediately.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|
ToDictionary<TKey, TValue>(IEnumerable<(TKey Key, TValue Value)>, IEqualityComparer<TKey>?)
Creates a Dictionary<TKey, TValue> from a sequence of tuples of 2 where the first item is the key and the second the value. An additional parameter specifies a comparer for keys.
Declaration
[Obsolete("This method has been implemented by the framework.")]
public static Dictionary<TKey, TValue> ToDictionary<TKey, TValue>(IEnumerable<(TKey Key, TValue Value)> source, IEqualityComparer<TKey>? comparer) where TKey : notnull
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<(TKey Key, TValue Value)> | source | The source sequence of couples (tuple of 2). |
IEqualityComparer<TKey> | comparer | The comparer for keys. |
Returns
Type | Description |
---|---|
Dictionary<TKey, TValue> | A Dictionary<TKey, TValue> containing the values mapped to their keys. |
Type Parameters
Name | Description |
---|---|
TKey | The type of the key. |
TValue | The type of the value. |
Remarks
This method executes immediately.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|