SHARE
TWEET

Untitled

a guest May 27th, 2017 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace HomeWork
  6. {
  7.     class Program
  8.     {
  9.         static void Main()
  10.         {
  11.             var phonebook = new Dictionary<string, string>();
  12.             var input = Console.ReadLine();
  13.             while (input.ToLower() != "search")
  14.             {
  15.                 var args = input.Split('-');
  16.                 var person = args[0];
  17.                 var number = args[1];
  18.  
  19.                 if (phonebook.ContainsKey(person)) phonebook[person] = number;
  20.                 else phonebook.Add(person, number);
  21.  
  22.                 input = Console.ReadLine();
  23.             }
  24.             var name = Console.ReadLine();
  25.             while (name.ToLower() != "end")
  26.             {
  27.                 Console.WriteLine(
  28.                     phonebook.ContainsKey(name) ?
  29.                     $"{name} -> {phonebook[name]}" :
  30.                     $"Contact {name} does not exist."
  31.                     );
  32.  
  33.                 name = Console.ReadLine();
  34.             }
  35.         }
  36.     }
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top