namespace Infosys.TelephoneDirectory
{
class Program
{
static void Main(string[] args)
{
SortedList myPhoneBook = new SortedList();
myPhoneBook.Add("Pat", 9932001343);
myPhoneBook.Add("Ted", 8956412745);
myPhoneBook.Add("Sam", 9243761256);
myPhoneBook.Add("Ann", 9546300876);
Console.WriteLine("Please enter a name to display the details:");
string searchName = Console.ReadLine();
int flag = 0;
foreach (object name in myPhoneBook.Keys)
{
//String.Compare(string str1,string str2,bool ignoreCase) method
//is used here for case insensitive comparison
if (String.Compare(name.ToString(), searchName, true) == 0)
{
Console.WriteLine("Search Results are:");
// LINE 01 : Code to display the output
flag = 1;
break;
}
}
if (flag == 0)
Console.WriteLine("No contacts found!");
}
}
}
Choose the correct option that needs to be written at LINE 01 inside Main() method in order to achieve the following output, when the user enters "Ted" as the input?
Please enter a name to display the details:
Ted
Search Results are:
Contact Name : Ted
Contact No. : 8956412745