Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当您使用ConcurrentDictionary并尝试向其添加新的密钥对时,它TryAdd会检查值是否存在,如果不存在则添加。有什么方法可以添加具有不同值的重复键吗?或者也许有替代的线程安全字典允许这样做?
ConcurrentDictionary
TryAdd
AConcurrentDictionary<TKey, TValue>不能包含重复的键。
ConcurrentDictionary<TKey, TValue>
ConcurrentBag<KeyValuePair<string, string>>如果订购不是问题,我会选择 a ,或者您可以使用 a并ConcurrenyDictionary <string, List<string>>根据需要过滤掉正确的值。
ConcurrentBag<KeyValuePair<string, string>>
ConcurrenyDictionary <string, List<string>>