• + 1 comment

    Thank you! I feel like C# isn't very well represented here, and I glad someone put up an example. I didn't realize you could use a while loop with a ReadLine like that. I can tell you one thing though, you can shorten your code a bit by using try and catch instead of flagFound and if-else statements. THANK YOU AGAIN!

    using System; using System.Collections.Generic; using System.IO; class Solution { static void Main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ int numberOfEntries = Convert.ToInt32(Console.ReadLine()); Dictionary phoneBook = new Dictionary();

        for(int i = 1; i <= numberOfEntries; i++)
        {
            string[] phoneBook_temp = Console.ReadLine().Split(' ');
            phoneBook[phoneBook_temp[0]] = phoneBook_temp[1];
        }
    
        string userInput;
        while((userInput = Console.ReadLine()) != null)
        {
            try
            {
                Console.WriteLine(userInput + "=" + phoneBook[userInput]);
            }
            catch
            {
                Console.WriteLine("Not found");
            }
        }
    }
    

    }