-
Notifications
You must be signed in to change notification settings - Fork 35
M_CodeJam_Collections_EnumerableExtensions_ToDictionary__2
Andrew Koryavchenko edited this page Jun 17, 2018
·
1 revision
EnumerableExtensions.ToDictionary(T, TKey) Method (IEnumerable(T), Func(T, TKey), DictionaryDuplicate)
Creates a Dictionary(TKey, TValue) from an IEnumerable(T) according to a specified key selector function and a duplicate handling policy.
Namespace: CodeJam.Collections
Assembly: CodeJam (in CodeJam.dll) Version: 2.1.0.0
C#
public static Dictionary<TKey, T> ToDictionary<T, TKey>(
this IEnumerable<T> source,
Func<T, TKey> keySelector,
DictionaryDuplicate duplicateHandling
)
VB
<ExtensionAttribute>
Public Shared Function ToDictionary(Of T, TKey) (
source As IEnumerable(Of T),
keySelector As Func(Of T, TKey),
duplicateHandling As DictionaryDuplicate
) As Dictionary(Of TKey, T)
F#
[<ExtensionAttribute>]
static member ToDictionary :
source : IEnumerable<'T> *
keySelector : Func<'T, 'TKey> *
duplicateHandling : DictionaryDuplicate -> Dictionary<'TKey, 'T>
- source
- Type: System.Collections.Generic.IEnumerable(T)
An IEnumerable(T) to create a Dictionary(TKey, TValue) from. - keySelector
- Type: System.Func(T, TKey)
A function to extract a key from each element. - duplicateHandling
- Type: CodeJam.Collections.DictionaryDuplicate
Policy for duplicate handling.
- T
- The type of the elements of source.
- TKey
- The type of the key returned by keySelector.
Type: Dictionary(TKey, T)
A Dictionary(TKey, TValue) that contains keys and values.
In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable(T). When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
EnumerableExtensions Class
ToDictionary Overload
CodeJam.Collections Namespace