Reputation: 1231
I have to copy one dictionary, work with that copy and return to the original one.
What seems to happen is that the orignal dictionary is modified when I do some work on the copied one.
Here is my code :
dmodified_profile = new SortedDictionary<int,SortedDictionary<string,List<string>>>(d_profile);
I don't know why d_profile which is the original one could be modified if my modifications are done on the dmodified_profile dictionary ?
Thanks
Upvotes: 1
Views: 153
Reputation: 59446
Your SortedDictionary maps an integer to a REFERENCE to another SortedDictionary. When you copy that dictionary you copy the values of the keys as well as the REFERENCEs of the values, because your dictionary's value is of a reference type.
Upvotes: 3