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 实现了 IDictionary 接口,尽管该接口支持 Add,但 ConcurrentDictionary 没有该功能。这是如何运作的?我认为接口强加了实现类的功能......
它使用显式接口实现。这是一个例子。
interface IFoo { void Foo(); } class FooImplementation : IFoo { void IFoo.Foo() { } }
如果您分配或强制ConcurrentDictionary转换为IDictionary,您可以使用那里定义的所有方法。
ConcurrentDictionary
IDictionary