En cuanto a System.Collections.Generic.Dictionary<TKey, TValue>
, claramente implementa ICollection<KeyValuePair<TKey, TValue>>
, pero no tiene la función "void Add(KeyValuePair<TKey, TValue> item)
" requerida.C#: ¿Cómo puede Dictionary <K,V> implementar ICollection <KeyValuePair <K,V>> sin tener Add (KeyValuePair <K,V>)?
Esto también se puede ver cuando se trata de inicializar un Dictionary
así:
private const Dictionary<string, int> PropertyIDs = new Dictionary<string, int>()
{
new KeyValuePair<string,int>("muh", 2)
};
el que falla con
No hay sobrecarga para el método 'Añadir' toma argumentos '1'
¿Por qué es así?
{new KeyValuePair ("muh", 2)} –
prabhakaran