Adding and removing of dictionaries elements in C#
Forums:
var dic = new Dictionary<int, String>();
dic[1] = "one";
dic[2] = "two";
dic[3] = "tree";
//dic is {{1, "one"}, {2, "two"}, {2, "tree"}}
dic[3] = "three";
//dic is {{1, "one"}, {2, "two"}, {2, "three"}}
dic.Remove(3);
//dic is {{1, "one"}, {2, "two"}}
dic.Clear();
//dic is empty
- Log in to post comments