We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Maybe another output option would be interesting to you.
...
string query;
while ((query = Console.ReadLine()) != null) // Read to the end. It is also suitable if the number of names being checked is unknown.
{
if (phoneList.TryGetValue(query, out string phone))
Console.WriteLine($"{query}={phone}");
else
Console.WriteLine("Not found");
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 8: Dictionaries and Maps
You are viewing a single comment's thread. Return to all comments →
Maybe another output option would be interesting to you.
...
string query;
while ((query = Console.ReadLine()) != null) // Read to the end. It is also suitable if the number of names being checked is unknown.
{
if (phoneList.TryGetValue(query, out string phone))
Console.WriteLine($"{query}={phone}");
else
Console.WriteLine("Not found");
}