Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication7
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, string> phonebook = new Dictionary<string, string>();
- string input = Console.ReadLine();
- string[] inputData = input.Split('-');
- while (input != "search")
- {
- phonebook.Add(inputData[0], inputData[1]);
- input = Console.ReadLine();
- inputData = input.Split('-');
- }
- Console.Clear();
- string name = Console.ReadLine();
- int counter = 0;
- while (counter == 0)
- {
- if (phonebook.ContainsKey(name) == false)
- {
- Console.WriteLine("Contact {0} does not exist.", name);
- }
- else
- {
- Console.WriteLine("{0} --> {1}", name, phonebook[name]);
- }
- name = Console.ReadLine();
- }
- //foreach (var name in phonebook.Keys)
- //{
- // Console.WriteLine("{0} --> {1}", name, phonebook[name]);
- //}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment