I declared a Dictionary type object and try to add some items into it. But I cannot modify even the value of the item. It's reasonable that key should not be modifiable, but why not the value? Thanks.
Dictionary<string, string> dict = new Dictionary<string, string>();
dict.Add("1", "bob");
dict.Add("2", "jack");
dict.Add("3", "wtf");
foreach (string key in dict.Keys)
{
dict[key] = "changed"; //System.InvalidOperationException: Collection was modified
}