2010-04-04 4 views

Répondre

4

Il suffit de passer au constructeur:

var copy = new SortedDictionary<string, int>(original); 
1

SortedDictionary<TKey,TValue> ne fournit pas une fonction AddRange(IEnumerable<KeyValuePair<TKey, TValue>>), de sorte que vous aurez à faire à la dure, un élément à la fois.

SortedDictionary<string, int> first, second; 
first = FillFirst(); 
second = FillSecond(); 

foreach (KeyValuePair<string, int> kvp in second) { 
    first.Add(kvp.Key, kvp.Value); 
} 
Questions connexes