[英]Is there a c# equivalent of Java ConcurrentHashMap
I need a dictionary/hashmap in c# that allow you to do the following 我需要c#中的字典/ hashmap,允许您执行以下操作
Thanks 谢谢
check out the System.Collections.Concurrent - Namespace! 看看System.Collections.Concurrent - 命名空间! http://msdn.microsoft.com/en-us/library/system.collections.concurrent.aspx http://msdn.microsoft.com/en-us/library/system.collections.concurrent.aspx
对于我来说,这听起来像ConcurrentDictionary<TKey, TValue>
,如果您安装了Reactive Extensions ,则可以在.NET 4.0 或 .NET 3.5中使用。
Have a look at the ConcurrentDictionary here: http://msdn.microsoft.com/en-us/library/dd287191.aspx . 在这里查看ConcurrentDictionary: http : //msdn.microsoft.com/en-us/library/dd287191.aspx 。 This should do what you're looking for. 这应该做你想要的。 Keep in mind, it's .Net 4 only. 请记住,它只是.Net 4。
You could also write your own class by using the ReaderWriterLockSlim Class
. 您也可以使用ReaderWriterLockSlim Class
编写自己的ReaderWriterLockSlim Class
。
Otherwise simply take a look into the System.Collections.Concurrent Namespace
. 否则,只需查看System.Collections.Concurrent Namespace
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.