public static Collectionary <TKey, TValue> ToCollectionary <TKey, TValue>(this IEnumerable <TValue> collection, Func <TValue, TKey> keySelector, IEqualityComparer <TValue> comparer) { var collectionary = new Collectionary <TKey, TValue>(comparer); foreach (var item in collection) { collectionary.Add(keySelector(item), item); } return(collectionary); }
public static Collectionary <TKey, TValue> ToCollectionary <TKey, TValue>(this IEnumerable <TValue> collection, Func <TValue, TKey> keySelector, bool makeUnique = false) { var collectionary = new Collectionary <TKey, TValue>(makeUnique); foreach (var item in collection) { collectionary.Add(keySelector(item), item); } return(collectionary); }