Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace Test
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, string> forms = new Dictionary<string, string>();
- int userInput;
- bool isUserInProgramm = true;
- while (isUserInProgramm) {
- Console.WriteLine("1 - Добавить досье | 2 - Посмотреть все досье | 3 - Удалить досье | 4 - Выйти из программы");
- userInput = Convert.ToInt32(Console.ReadLine());
- switch (userInput)
- {
- case 1:
- AddForm(forms);
- break;
- case 2:
- ShowForms(forms);
- break;
- case 3:
- DeleteForm(forms);
- break;
- case 4:
- isUserInProgramm = false;
- break;
- }
- Console.WriteLine("Нажмите любую клавишу для продолжения...");
- Console.ReadKey();
- Console.Clear();
- }
- }
- public static void AddForm(Dictionary<string, string> dict)
- {
- Console.WriteLine("Введите полное имя: ");
- string fullName = Console.ReadLine();
- Console.WriteLine("Введите Должность: ");
- string post = Console.ReadLine();
- dict.Add(fullName, post);
- }
- public static void DeleteForm(Dictionary<string, string> dict)
- {
- Console.WriteLine("Введите имя чьё досье вы хотите удалить: ");
- string fullName = Console.ReadLine();
- if (dict.Remove(fullName))
- {
- Console.WriteLine("Досье удалено");
- }
- else
- {
- Console.WriteLine("Досье не найдено");
- }
- }
- public static void ShowForms(Dictionary<string, string> dict)
- {
- int i = 0;
- Console.WriteLine("Список досье:");
- foreach (var name in dict)
- {
- i++;
- Console.WriteLine($"{i}.{name.Key} - {name.Value}");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment