ConcurrentDictionary and IDictionary

I noticed that ConcurrentDictionary implements the IDictionary interface, but although the interface supports Add, ConcurrentDictionary does not have this function. How it works? I thought interfaces impose functionality on implementation classes ...

0
source share
1 answer

It uses an explicit implementation of the interface. Here is an example.

interface IFoo
{
   void Foo();
}

class FooImplementation : IFoo
{
   void IFoo.Foo()
   {
   }
}

If you assign or drop ConcurrentDictionaryin IDictionary, you can use all the methods defined there.

+1
source

Source: https://habr.com/ru/post/1527447/


All Articles