Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Dictionaries
- {
- class Program
- {
- public static void Main(string[] args)
- {
- Dictionary<string, string> phoneDetails = new Dictionary<string, string>();
- List<string> commands = Console.ReadLine().Split(' ').ToList();
- string token = commands[0];
- while (token != "END")
- {
- switch (token)
- {
- case "A":
- string index = commands[1];
- string entry = commands[2];
- phoneDetails.Add(index, entry);
- break;
- case "S":
- string searched = commands[1];
- string result = null;
- if (phoneDetails.TryGetValue(searched, out result))
- {
- Console.WriteLine("{0} -> {1}", searched, result);
- }
- else
- {
- Console.WriteLine("Contact {0} does not exist.", searched);
- }
- break;
- }
- commands = Console.ReadLine().Split(' ').ToList();
- token = commands[0];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement