Skip to content

Instantly share code, notes, and snippets.

@ShamilAitov
Last active April 19, 2023 22:36
Show Gist options
  • Save ShamilAitov/70a9fa65fc1594b92480536dec6c3138 to your computer and use it in GitHub Desktop.
Save ShamilAitov/70a9fa65fc1594b92480536dec6c3138 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
namespace Коллекции1задание
{
internal class Program
{
static void Main(string[] args)
{
string userInput;
bool bookNotFound = true;
Dictionary<string, string> text = new Dictionary<string, string>
{
{ "Цвет", "Зеленый" },
{ "Машина", "Мерседес" },
{ "Недвижимость", "Коттедж"},
{ "Деньги", "Крипта"},
{ "Драгоценность", "Золото"},
{ "Работа", "Разработчик" },
{ "Город", "Пенза" }
};
while (bookNotFound)
{
if (FindingWord(text, out userInput))
{
Console.WriteLine($"Найдено слово по ключу {userInput}: " + text[userInput]);
bookNotFound = false;
}
else
{
Console.WriteLine("Такого слова нет, попройбуйте еще раз!");
}
}
}
static bool FindingWord(Dictionary<string, string> text, out string userInput)
{
Console.Write("Введите слово, которое нужно найти: ");
userInput = Console.ReadLine();
return text.ContainsKey(userInput);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment