Checking of presence of a dictionary key in C#
Forums:
var dic = new Dictionary<int, String> { { 1, "one" }, { 2, null } };
var exists1 = dic.ContainsKey(1);
//exists1 is True
var exists2 = dic.ContainsKey(2);
//exists2 is True
var exists3 = dic.ContainsKey(3);
//exists3 is False
- Log in to post comments