How to modify key in a dictionary in C#

后端 未结 4 1185
刺人心
刺人心 2020-12-01 07:30

How can I change the value of a number of keys in a dictionary.

I have the following dictionary :

SortedDictionary

        
4条回答
  •  鱼传尺愫
    2020-12-01 08:01

    You need to remove the items and re-add them with their new key. Per MSDN:

    Keys must be immutable as long as they are used as keys in the SortedDictionary(TKey, TValue).

提交回复
热议问题