How to modify key in a dictionary in C#

后端 未结 4 1183
刺人心
刺人心 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 07:49

    You can use LINQ statment for it

    var maxValue = 10
    sd= sd.ToDictionary(d => d.key > maxValue ? d.key : d.Key +1, d=> d.Value);
    

提交回复
热议问题