Advertisement
Guest User

phoneBook

a guest
Oct 20th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Dict_Lambda_LINQ___Exercise___15._10._2017
  8. {
  9. class PhoneBook
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. string[] splittedCommand = Console.ReadLine().Trim().Split(' ');
  15. Dictionary<string, string> phonebook = new Dictionary<string, string>();
  16.  
  17. while (splittedCommand[0] != "END")
  18. {
  19. if (splittedCommand[0] == "A")
  20. {
  21. phonebook[splittedCommand[1]] = splittedCommand[2];
  22. }
  23. else if (splittedCommand[0] == "S")
  24. {
  25. if (phonebook.ContainsKey(splittedCommand[1]))
  26. {
  27. Console.WriteLine(phonebook[splittedCommand[1]] + "->" + splittedCommand[2]);
  28. }
  29. else
  30. {
  31. Console.WriteLine("Contact {0} does not exist.", splittedCommand[1]);
  32. }
  33. }
  34. splittedCommand = Console.ReadLine().Split(' ');
  35. }
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement