Advertisement
gadjov

PhoneBook

Oct 13th, 2017
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. namespace PhoneBook
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.  
  6.     public class Startup
  7.     {
  8.         public static void Main()
  9.         {
  10.             string input;
  11.             Dictionary<string, string> phoneBook = new Dictionary<string, string>();
  12.             while ((input = Console.ReadLine()) != "END")
  13.             {
  14.                 string[] inputArgs = input
  15.                     .Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
  16.  
  17.                 if (inputArgs.Length == 3)
  18.                 {
  19.                     phoneBook[inputArgs[1]] = inputArgs[2];
  20.                     continue;
  21.                 }
  22.                 Console.WriteLine(phoneBook.ContainsKey(inputArgs[1]) ? $"{inputArgs[1]} -> {phoneBook[inputArgs[1]]}" : $"Contact {inputArgs[1]} does not exist.");
  23.             }
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement