Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string input = "";
- string[] commands;
- var phonebook = new SortedDictionary<string, string>();
- while (input != "END")
- {
- input = Console.ReadLine();
- commands = input.Split();
- if (commands[0] == "A")
- {
- if (phonebook.ContainsKey(commands[1]))
- {
- phonebook[commands[1]] = commands[2];
- }
- else
- {
- phonebook.Add(commands[1], commands[2]);
- }
- }
- else if (commands[0] == "S")
- {
- if (phonebook.ContainsKey(commands[1]))
- {
- Console.WriteLine(commands[1] + " -> " + phonebook[commands[1]]);
- }
- else
- {
- Console.WriteLine("Contact {0} does not exist.", commands[1]);
- }
- }
- else if (commands[0] == "ListAll") {
- foreach (var item in phonebook)
- {
- Console.WriteLine(item.Key + " -> " + item.Value);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement