Search code examples
c#resharper

Difference between IDictionary and IEnumerable<KeyValuePair>


Resharper is suggesting that I change IDictionary<string, string> in the following line of code:

private static void createCookie(HttpCookie cookie, IDictionary<string, string> values)

to IEnumerable<KeyValuePair<string, string>>.

I don't understand the advantage to using IEnumerable<KeyValuePair<string, string>> over IDictionary.


Solution

  • Resharper noticed that you are not doing anything dictionary-specific in your code, so it suggest to allow more generic objects to be accepted as well. All you are doing in your code, you can also do with an IEnumerable<KeyValuePair<string, string>>.