Advertisement
asvd32

dossiers Dictionary

Jun 5th, 2022
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4.  
  5. namespace ConsoleApp3
  6. {
  7.     internal class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             Dictionary<string, string> dossiers = new Dictionary<string, string>();
  12.             bool isRun = true;
  13.             string userInput;
  14.  
  15.             while (isRun)
  16.             {
  17.                 userInput = Console.ReadLine();
  18.  
  19.                 switch (userInput)
  20.                 {
  21.                     case "1":
  22.                         dossiers.Add(Console.ReadLine(), Console.ReadLine());
  23.                         break;
  24.                     case "2":
  25.                         string tempKey = Console.ReadLine();
  26.                         if (dossiers.ContainsKey(tempKey))
  27.                         {
  28.                             dossiers.Remove(tempKey);
  29.                         }
  30.                         else
  31.                         {
  32.                             Console.WriteLine("Досье не найденно");
  33.                         }          
  34.                         break;
  35.                     case "3":
  36.                         if (dossiers.Count > 0)
  37.                         {
  38.                             foreach (var elemnt in dossiers)
  39.                             {
  40.                                 Console.WriteLine($"{elemnt.Key} - {elemnt.Value}");
  41.                             }
  42.                         }
  43.                         else
  44.                         {
  45.                             Console.WriteLine("Список досье пуст.");
  46.                         }                        
  47.                         break;
  48.                     case "4":
  49.                         isRun = false;
  50.                         break;
  51.                 }
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement