Jeśli nie przeszkadza odtworzenie słownika, można użyć statment LINQ.
var dictionary = new SortedDictionary<int, SortedDictionary<string, List<string>>>();
var insertAt = 10;
var newValues = dictionary.ToDictionary(
x => x.Key < insertAt ? x.Key : x.Key + 1,
x => x.Value);
return new SortedDictionary<int, SortedDictionary<string, List<string>>>(newValues);
lub
var dictionary = new SortedDictionary<int, SortedDictionary<string, List<string>>>();
var insertAt = 10;
var newValues = dictionary.ToDictionary(
x => x.Key < insertAt ? x.Key : x.Key + 1,
x => x.Value);
dictionary.Clear();
foreach(var item in newValues) dictionary.Add(item.Key, item.Value);
Dlaczego ten przegłosowana? – keyboardP
Nie można zmodyfikować klucza. Zamiast tego usuń klucz i dodaj nową wartość dla klucza + 1 –
To pytanie brzmi, jakbyś próbował ręcznie wstawić element i zachować go (w szczególności, robiąc miejsce dla jednego). Zauważ, że SortedDictionary już to robi. – Russell