IDictionary和IEnumerable <KeyValuePair>之间的区别

bfl*_*mi3 3 c# resharper

Resharper建议我更改IDictionary<string, string>以下代码行:

private static void createCookie(HttpCookie cookie, IDictionary<string, string> values)
Run Code Online (Sandbox Code Playgroud)

IEnumerable<KeyValuePair<string, string>>.

我不明白使用IEnumerable<KeyValuePair<string, string>>over 的优势IDictionary.

Jan*_*aus 6

Resharper注意到你没有在你的代码中做任何字典特定的事情,所以它建议允许更多的通用对象被接受.你在代码中所做的一切,你也可以用IEnumerable<KeyValuePair<string, string>>.