c# - IDictionary 和 IEnumerable<KeyValuePair> 之间的区别

标签 c# resharper

Resharper 建议我更改 IDictionary<string, string>在下面的代码行中:

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

IEnumerable<KeyValuePair<string, string>> .

我不明白使用 IEnumerable<KeyValuePair<string, string>> 的好处在 IDictionary .

最佳答案

Resharper 注意到您没有在代码中执行任何特定于字典的操作,因此它建议也允许接受更多通用对象。您在代码中所做的一切,您也可以使用 IEnumerable<KeyValuePair<string, string>> 来完成.

关于c# - IDictionary 和 IEnumerable<KeyValuePair> 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17450127/

相关文章:

C# 中的 Javascript 对象

c# - ReSharper 9 "File Layout/Type Member Layout"无区域

C# - 通过子类实现的接口(interface)继承和使用时找不到方法的用法

resharper - 为什么 IntelliSense 不断将函数更改为函数?

c# - Akavache 无效

c# - Windows 窗体字体粗细

c# - Resharper:有没有办法修改清理代码/更新文件头的行为?

Javascript代码分析和常量

c# - 为什么不可访问的成员被认为是继承的?

c# - 如何使用 ReactiveList 以便在添加新项目时更新 UI