Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added ToDictionary

  • Loading branch information...
commit 0ba96fc0c539ea53148302c90164fe14f835890e 1 parent 2b87c36
@adrianaisemberg authored
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
Please sign in to comment.
Something went wrong with that request. Please try again.