Browse files

added ToDictionary

  • Loading branch information...
1 parent 2b87c36 commit 0ba96fc0c539ea53148302c90164fe14f835890e @adrianaisemberg committed Mar 12, 2012
Showing with 15 additions and 0 deletions.
  1. +15 −0 CLAP/FW2Stuff.cs
View
15 CLAP/FW2Stuff.cs
@@ -279,6 +279,21 @@ public static List<T> ToList<T>(this IEnumerable<T> collection)
return list;
}
+
+ public static Dictionary<TKey, TElement> ToDictionary<TSource, TKey, TElement>(
+ this IEnumerable<TSource> source,
+ Func<TSource, TKey> keySelector,
+ Func<TSource, TElement> elementSelector)
+ {
+ var dict = new Dictionary<TKey, TElement>();
+
+ foreach (var item in source)
+ {
+ dict.Add(keySelector(item), elementSelector(item));
+ }
+
+ return dict;
+ }
}
#endregion Enumerable

0 comments on commit 0ba96fc

Please sign in to comment.