IDictionary<TKey, TValue>
extends from interface ICollection<KeyValuePair<TKey, TValue>>
, so it has an Add(KeyValuePair<TKey, TValue> item)
method:
IDictionary<string, object> dic = new Dictionary<string, object>();
dic.Add(new KeyValuePair<string, object>("number", 42)); // Compiles fine
However, although Dictionary<TKey, Tvalue>
implements IDictionary<TKey, TValue>
, it does not have this method overload:
Dictionary<string, object> dic = new Dictionary<string, object>();
dic.Add(new KeyValuePair<string, object>("number", 42)); // Does not compile
How can this be?