Forked from ShamilAitov/gist:70a9fa65fc1594b92480536dec6c3138
Last active
April 19, 2023 17:32
-
-
Save GigaOrts/717c76f23296eef761a5733e1f118fc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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