Dictionary
if (Employee .TryGetValue("Jim", out value))
{
Console.WriteLine("For key = \"Employee\", value = {0}.", value);
else
Console.WriteLine("Key = \"Employee\" is not found.");
}Contains can also be used to search through the dictionary obejct, but used mostly inserting a new value into the dictionary, it checks and then adds.
if (Employee .ContainsKey("Jim"))
{
flag = true; //search value found
}
else
flag = false;//search value not found
No comments:
Post a Comment