Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Dictionaries__Lambda__Linq_Exercise
- {
- public class PhoneBook
- {
- public static void Main(string[] args)
- {
- var phonebook = new SortedDictionary<string, string>();
- var input = Console.ReadLine().Split().ToList();
- while (input[0]!="END")
- {
- if (input[0] == "A")
- {
- phonebook[input[1]] = input[2];
- }
- else if (input[0] == "S")
- {
- if (phonebook.ContainsKey(input[1]))
- {
- Console.WriteLine($"{input[1]} -> {phonebook[input[1]].ToString()}");
- }
- else
- {
- Console.WriteLine($"Contact {input[1]} does not exist.");
- }
- }
- input = Console.ReadLine().Split().ToList();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement