Dictionary Extension Methods

The following extension methods are defined for the Dictionary<TKey, TValue> type:

  • void AddRange<TKey, TValue>(Func<TValue, TKey> keyProducerFunc, IEnumerable<TValue> rangeToAdd).
    Adds the range rangeToAdd to the dictionary specified, using the Func keyProducerFunc to produce the key values. If the key already exists, the key's value is overwritten with the value to add.
  • TValue GetValue<TKey, TValue>(TKey key).
    Gets the value for the key from the dictionary specified, or null / default(TValue) if key not found or the key is null.

Last edited Nov 27, 2010 at 12:28 PM by SolutionsDesign, version 5


PauloMorgado Dec 5, 2010 at 5:24 PM 
I agree with mihailik. It should also have an overload to provide what the delaut is for that call.

mihailik Nov 29, 2010 at 10:38 AM 
GetValue should be GetValueOrDefault to follow existing BCL pattern.