I have the following code:
Dictionary<int, int> test = new Dictionary<int, int>();
test.Add(1,1);
test.Add(2, 2);
Dictionary<int, int> test2 = test;
test2.Remove(1);
Removing item from test2 is removing the item from test object too. Can you tell me how to modify items from test2 without affecting test?
test2 and test are the same reference to the same object (dictionary). Instantiate a new dictionary for test2.