为什么不字典都的AddRange?字典、AddRange

2023-09-03 00:43:03 作者:欲望沦陷世人

标题是基本够​​用,为什么不能我:

 词典<字符串,字符串> DIC =新字典<字符串,字符串>();
dic.AddRange(MethodThatReturnAnotherDic());
 

解决方案

范围并不真正具有任何意义的关联容器不是吗?我认为字典并将其存储在一个列表值,但不是唯一的哈希表。

总之,用C#可以编写合并词典你自己的扩展方法。

Title is basic enough, why can't I:

Dictionary<string, string> dic = new Dictionary<string, string>();
dic.AddRange(MethodThatReturnAnotherDic());
VBA怎么用字典判断一个区域 A1 B60000 中有没有重复值

解决方案

Range doesn't really have any meaning to an associative container does it? I think Dictionary stores it's values in a sorted fashion, but that isn't unique to Hashtables.

Anyway, with C# you can write your own extension method to merge dictionaries.