Skip to content

Instantly share code, notes, and snippets.

@wwahammy
Created February 21, 2013 22:01
Show Gist options
  • Save wwahammy/5008687 to your computer and use it in GitHub Desktop.
Save wwahammy/5008687 to your computer and use it in GitHub Desktop.
A ToDictionary method that should have already been in LINQ
//usage: filteredDictionary = someDictionary.Where(kv => kv.Key != "KeyToFilterOut").ToDictionary();
public static Dictionary<T1, T2> ToDictionary<T1, T2>(this IEnumerable<KeyValuePair<T1, T2>> input) {
return input.ToDictionary(kv => kv.Key, kv => kv.Value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment