Dictionary Extension Method - Append

I've been creating a few extension methods here and there recently and figured I'd share one of the ones I'm using in a lot of places. This one is an extension method named Append that you can use with a generic IDictionary implementor to do quick-and-dirty creations of the object. I've found this to be really useful when I'm writing tests that use the generic IDictionary class in my tests. The first block of code below will point out the extension method.


public static class DictionaryExtensions
  public static IDictionary<TKey, TValue> Append<TKey, TValue>(this IDictionary<TKey,TValue> dictionary,
    TKey key, TValue value)
    dictionary.Add(key, value);
    return dictionary;


This second block demonstrates one potential use for it. In this case I was creating a generic Dictionary to store name/value pairs of data for an HTTP post. 


IDictionary<string, string> prms = new Dictionary<string, string>().Append("status", status);


Happy coding!