我有一個要求,我已經有一個現有的SortedDictionary<string, int>
。現在我正在創建一個不同的SortedDictionary
,並且希望在第一個中添加這個。怎麼做?SortedDictionary將一個SortedDictionary添加到另一個SortedDictionary
1
A
回答
4
它只是傳遞給構造函數:
var copy = new SortedDictionary<string, int>(original);
1
SortedDictionary<TKey,TValue>
不提供AddRange(IEnumerable<KeyValuePair<TKey, TValue>>)
功能,所以你必須做硬盤的方式,一個項目在一個時間。
SortedDictionary<string, int> first, second;
first = FillFirst();
second = FillSecond();
foreach (KeyValuePair<string, int> kvp in second) {
first.Add(kvp.Key, kvp.Value);
}
相關問題
- 1. deepcopy的一個SortedDictionary
- 2. SortedDictionary <TKey,TValue>:檢查內容是否等於另一個SortedDictionary?
- 3. 上SortedDictionary
- 4. SortedDictionary behavior
- 5. WP7 SortedDictionary
- 6. 設置一個SortedDictionary的第i個值
- 7. SortedDictionary中的第一項?
- 8. SortedDictionary在C
- 9. SortedDictionary重複鍵?
- 10. 獲取SortedDictionary的最後一個元素
- 11. 使用SortedDictionary - 獲取下一個值
- 12. SortedList與SortedDictionary與Sort()
- 13. 獲得第i個值或SortedDictionary
- 14. 爲什麼我無法將新對添加到SortedDictionary中?
- 15. F#相當於SortedDictionary從C#
- 16. SortedDictionary中的數字格式
- 17. 索引檢索SortedDictionary <>
- 18. SortedDictionary投影使用linq
- 19. 遍歷改變的SortedDictionary
- 20. SortedDictionary是紅黑樹嗎?
- 21. 應對變化的SortedDictionary
- 22. 使用SortedDictionary TakeWhile返回空
- 23. 如何將自定義IComparer用於SortedDictionary?
- 24. 獲取一個等於來自SortedDictionary的項目的鍵嗎?
- 25. 在sortedDictionary中打印列表對象
- 26. 比較SortedDictionary的鍵的類型
- 27. 如何在c#中正確使用SortedDictionary?
- 28. C#SortedDictionary產生異常結果
- 29. 排序列表/ SortedDictionary怪異的行爲
- 30. 如何排序鍵SortedDictionary收集字母
是對第二也是SortedDictionary還是一個SortedDictionary <東西,SortedDictionary >? –
2010-04-04 18:51:59