如何修改keyvaluepair价值? [英] How to modify a keyvaluepair value?
本文介绍了如何修改keyvaluepair价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题,当我尝试修改
i got a problem when i try to modify the value of an
KeyValuePair<Tkey, Tvalue>
项目,因为它只是一个只读字段。
我试着像
item because its only a read only field. I try different alternatives like a
Dictionary<Tkey, Tvalue>
但我有同样的问题。有没有办法将值字段设置为一个新的价值?
but there i have the same problem. Is there a way to set the value field to an new value?
此致
KIMBO
推荐答案
您不能修改它,你可以用一个新的更换。
You can't modify it, you can replace it with a new one.
var newEntry = new KeyValuePair<Tkey, Tvalue>(oldEntry.Key, newValue);
或词典:
dictionary[oldEntry.Key] = newValue;
这篇关于如何修改keyvaluepair价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文