Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GigaOrts/717c76f23296eef761a5733e1f118fc8 to your computer and use it in GitHub Desktop.
Save GigaOrts/717c76f23296eef761a5733e1f118fc8 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)
{
bool isNotFound = true;
Dictionary<string, string> dictionary = new Dictionary<string, string>
{
{ "Цвет", "Зеленый" },
{ "Машина", "Мерседес" },
{ "Недвижимость", "Коттедж" },
{ "Деньги", "Крипта" },
{ "Драгоценность", "Золото" },
{ "Работа", "Разработчик" }
};
while (isNotFound)
{
if(TrySearchWord(dictionary, out string userKey))
{
Console.WriteLine($"Найдено слово по ключу {userKey}: " + dictionary[userKey]);
isNotFound = false;
}
else
{
Console.WriteLine("Такого слова нет, попробуйте еще раз");
}
}
}
static bool TrySearchWord(Dictionary<string, string> dictionary, out string userKey)
{
Console.Write("Введите слово, которое нужно найти: ");
userKey = Console.ReadLine();
return dictionary.ContainsKey(userKey);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment