Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between IDictionary and IEnumerable<KeyValuePair>

Tags:

c#

resharper

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.

like image 235
bflemi3 Avatar asked Sep 18 '25 05:09

bflemi3


1 Answers

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>>.

like image 121
Jan Dörrenhaus Avatar answered Sep 20 '25 21:09

Jan Dörrenhaus