If I have ConcurrentDictionaryand want to use a function Add(), I need to send to IDictionary:
var cd = new ConcurrentDictionary<int, int>();
cd.Add(1, 1);
IDictionary<int, int> id = cd;
id.Add(1, 1);
The question of ConcurrentDictionary and IDictionary tells me this because it ConcurrentDictionaryexplicitly implements IDictionaryusing private methods.
My question is: Why does ConcurrentDictionaryit work like this? What is the advantage of hiding the use of an implemented interface?
source
share