Dictionary<int, string> dict = new Dictionary<int, string>();
// initial value for demonstration
dict.Add(1, "Test");
dict.Add(2, "Test2");
use below method to check whether a key is exist or not
if (!dict.ContainsKey(1))
dict.Add(1, "Test");
if (!dict.ContainsValue("Test"))
dict.Add(1, "Test");
// initial value for demonstration
dict.Add(1, "Test");
dict.Add(2, "Test2");
use below method to check whether a key is exist or not
if (!dict.ContainsKey(1))
dict.Add(1, "Test");
if (!dict.ContainsValue("Test"))
dict.Add(1, "Test");
No comments:
Post a Comment