-
Notifications
You must be signed in to change notification settings - Fork 35
M_CodeJam_Collections_EnumerableExtensions_ToDictionary__3
Andrew Koryavchenko edited this page Jun 17, 2018
·
1 revision
EnumerableExtensions.ToDictionary(T, TKey, TElement) Method (IEnumerable(T), Func(T, TKey), Func(T, TElement), DictionaryDuplicate)
Creates a Dictionary(TKey, TValue) from an IEnumerable(T) according to a specified key selector function, an element 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, TElement> ToDictionary<T, TKey, TElement>(
this IEnumerable<T> source,
Func<T, TKey> keySelector,
Func<T, TElement> elementSelector,
DictionaryDuplicate duplicateHandling
)
VB
<ExtensionAttribute>
Public Shared Function ToDictionary(Of T, TKey, TElement) (
source As IEnumerable(Of T),
keySelector As Func(Of T, TKey),
elementSelector As Func(Of T, TElement),
duplicateHandling As DictionaryDuplicate
) As Dictionary(Of TKey, TElement)
F#
[<ExtensionAttribute>]
static member ToDictionary :
source : IEnumerable<'T> *
keySelector : Func<'T, 'TKey> *
elementSelector : Func<'T, 'TElement> *
duplicateHandling : DictionaryDuplicate -> Dictionary<'TKey, 'TElement>
- 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. - elementSelector
- Type: System.Func(T, TElement)
A transform function to produce a result element value 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.
- TElement
- The type of the value returned by elementSelector.
Type: Dictionary(TKey, TElement)
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