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/