Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Extension method: Dictionary<TKey1, Dictionary<TKey2, TValue>> ToDictionary2<TSource, TKey1, TKey2, TValue>(this IEnumerable<TSource>, Func<TSource, TKey1>, Func<TSource, TKey2>, Func<TSource, TValue>, IEqualityComparer<TKey1>, IEqualityComparer<TKey2>)

Declaration

public static Dictionary<TKey1, Dictionary<TKey2, TValue>> ToDictionary2<TSource, TKey1, TKey2, TValue>(
    this IEnumerable<TSource> source,
    Func<TSource, TKey1> key1Selector,
    Func<TSource, TKey2> key2Selector,
    Func<TSource, TValue> elementSelector,
    IEqualityComparer<TKey1> comparer1 = null,
    IEqualityComparer<TKey2> comparer2 = null
)

Summary

Creates a two-level dictionary from an enumerable collection according to two specified key selector functions and optional key comparers.

Generic type parameters

TSource The type of the elements of source.
TKey1 The type of the keys returned by key1Selector.
TKey2 The type of the keys returned by key2Selector.
TValue The type of the value returned by elementSelector.

Parameters

this IEnumerable<TSource>source Source collection to create a dictionary from.
Func<TSource, TKey1>key1Selector A function to extract the first-level key from each element.
Func<TSource, TKey2>key2Selector A function to extract the second-level key from each element.
Func<TSource, TValue>elementSelector A transform function to produce a result element value from each element.
IEqualityComparer<TKey1>comparer1 An equality comparer to compare the first-level keys.
IEqualityComparer<TKey2>comparer2 An equality comparer to compare the second-level keys.