看着System.Collections.Generic.Dictionary<TKey, TValue>
,它清楚地實現了ICollection<KeyValuePair<TKey, TValue>>
,但沒有所需的「void Add(KeyValuePair<TKey, TValue> item)
」函數。C#:如何在沒有添加(KeyValuePair <K,V>)的情況下實施ICollection <KeyValuePair <K,V>>的字典<K,V>?
這也可以嘗試初始化一個Dictionary
這樣,當看到:
private const Dictionary<string, int> PropertyIDs = new Dictionary<string, int>()
{
new KeyValuePair<string,int>("muh", 2)
};
其失敗
的方法 '添加' 沒有重載採用 '1' 的論點
這是爲什麼呢?
{new KeyValuePair(「muh」,2)} –
prabhakaran
2014-03-21 05:58:14