I get a Dictionary<string, string> back from an API but depending on certain rules need to modify some of the key names.
Before I head down the road of copying to a new Dictionary I just wanted to confirm that the keys in a Dictionary<TKey, TValue> are immutable.
You are right, if the key changes, you will need to remove the entry with the old key and insert a new entry with the new key.
If only some of the keys change, you don’t need to copy the entire dictionary. Both Add and Remove operations on
Dictionaryare roughly O(1) operations.