Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- public class Program
- {
- public static void Main()
- {
- Dictionary<string, string> phonebook = new Dictionary<string, string>();
- while (true)
- {
- Console.WriteLine("1. Изпечатай целия тел. указател");
- Console.WriteLine("2. Добави нов номер");
- Console.WriteLine("3. Изтриий номер");
- Console.WriteLine("4. Потърси номер");
- Console.WriteLine("5. Излез");
- string command = Console.ReadLine();
- if (command == "1")
- {
- foreach (var el in phonebook)
- {
- Console.WriteLine("{0} -> {1}", el.Key, el.Value);
- }
- }
- else if (command == "2")
- {
- Console.Write("Въведи име и номер; ");
- string[] input = Console.ReadLine().Split(' ');
- phonebook[input[0]] = input[1];
- }
- else if (command == "3")
- {
- string[] input = Console.ReadLine().Split(' ');
- phonebook.Remove(input[0]);
- }
- else if (command == "4")
- {
- string name = Console.ReadLine();
- if (phonebook.ContainsKey(name))
- {
- Console.WriteLine(phonebook[name]);
- }
- else
- {
- Console.WriteLine("Номера не съществува");
- }
- }
- else if (command == "5")
- {
- break;
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement