Advertisement
RedFlys

CSharpLigth HomeWork - Dictionary

Jan 27th, 2021
672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace CSharpLigth_HomeWork_Dictionary
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string errorNoFound = "Такого слова пока нет в нашем словаре.";
  11.  
  12.             string userValue;
  13.  
  14.             Dictionary<string, string> words = new Dictionary<string, string>();
  15.             words.Add("группа", "Несколько предметов или людей, животных, расположенных близко друг от друга.");
  16.             words.Add("кот", "Самец кошки");
  17.  
  18.             Console.Write("Введите слово для поиска в словаре: ");
  19.             userValue = Console.ReadLine();
  20.  
  21.             if (words.ContainsKey(userValue))
  22.             {
  23.                 Console.WriteLine($"{userValue} - {words[userValue]}");
  24.             }
  25.             else
  26.             {
  27.                 Console.WriteLine(errorNoFound);
  28.             }
  29.  
  30.             Console.ReadLine();
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement