为什么并发字典没有可见的Add()方法? [英] Why does Concurrent Dictionary not have a visible Add() Method?

查看:64
本文介绍了为什么并发字典没有可见的Add()方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道ConcurrentDictionary没有在Visual Studio IDE中可见的Add方法的可能性.我似乎只得到了TryX方法,例如TryAdd,TryUpdate等.

I was just wondering how it was possible that ConcurrentDictionary does not have an Add method which is visible in the Visual Studio IDE. I only seem to get the TryX Methods e.g TryAdd, TryUpdate etc.

我可以看到ConcurrentDictionary实现了IDictionary,如果将其强制转换为IDictionary,我将获得Add方法.

I can see that the ConcurrentDictionary implements IDictionary and if I cast it to IDictionary I get the Add Method back.

我已经通过iLSpy查看了该类,并且可以看到Add方法已完全实现,并且实际上在后台调用了Concurrent TryAdd方法.

I have looked at the class through iLSpy and I can see the Add Method is fully implemented and does actually call the Concurrent TryAdd Method under the hood.

我期望在Add方法上看到某种属性来抑制它,但是我什么也没看到.

I was expecting to see some sort of Attribute on the Add method to surpress it but I am not seeing anything.

Microsoft是否已将其烘焙到IDE中以默认隐藏Add方法?

Has this been baked into the IDE by Microsoft to hide the Add method by default ??

如果有人可以对此有所了解,将不胜感激

If someone could shed some light on this it would be appreciated

推荐答案

这是因为显式接口实现.请参阅 http://msdn.microsoft.com/en -us/library/aa288461(v = vs.71).aspx

这篇关于为什么并发字典没有可见的Add()方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆