At the moment, I have no other way than this one (an indirect update):
private void UpdateKey(Dictionary<string,object> dict, string oldKey, string newKey){
if(dict.ContainsKey(oldKey)){
object value = dict[oldKey];
dict.Remove(oldKey);
dict.Add(newKey,value);
}
}
Do you have another better way?
Of course the above method is just a simple one, to make it work well without throwing any exception, we have to check the newKey for duplication with already keys in the Dictionary. Like this:
private void UpdateKey(Dictionary<string,object> dict, string oldKey, string newKey){
if(dict.ContainsKey(oldKey)){
object value = dict[oldKey];
dict.Remove(oldKey);
dict[newKey] = value;
}
}
Thank you very much in advance!