Betrachtet man System.Collections.Generic.Dictionary<TKey, TValue>
, implementiert es eindeutig ICollection<KeyValuePair<TKey, TValue>>
, hat aber nicht die erforderliche Funktion "void Add(KeyValuePair<TKey, TValue> item)
". C#: Wie kann Dictionary <K,V> ICollection implementieren <KeyValuePair <K,V>> ohne Add (KeyValuePair <K,V>)?
Dies kann auch gesehen werden, wenn ein Dictionary
so zu initialisieren versuchen:
private const Dictionary<string, int> PropertyIDs = new Dictionary<string, int>()
{
new KeyValuePair<string,int>("muh", 2)
};
, die mit
Keine Überlastung für Methode versagt 'Add' nimmt '1' Argumente
Warum ist das so?
{neue KeyValuePair ("muh", 2)} –
prabhakaran