Skip to content

Instantly share code, notes, and snippets.

@Strelok78
Last active April 22, 2025 16:35
Show Gist options
  • Select an option

  • Save Strelok78/6f8e1faf7139f14abd48ca3e6e69e39e to your computer and use it in GitHub Desktop.

Select an option

Save Strelok78/6f8e1faf7139f14abd48ca3e6e69e39e to your computer and use it in GitHub Desktop.
Vocabulary
using System.Collections;
using System.Diagnostics;
namespace iJuniorPractice;
class Program
{
static void Main(string[] args)
{
const string ExitCommand = "Выход";
bool isWork = true;
Dictionary<string, string> vocabulary = new Dictionary<string, string>()
{
{"Искра", "маленькая светящаяся частица, возникающая при горении или трении."},
{"Горизонт","линия, где небо кажется соприкасающимся с землёй."},
{"Эхо","отражение звука, слышимое как повторение."},
{"Маяк","сооружение, излучающее свет для навигации судов."},
{"Туман","густое облако водяных капель, снижающее видимость."}
};
while (isWork)
{
Console.WriteLine("Содержание словаря");
foreach (var word in vocabulary)
{
Console.WriteLine(word.Key);
}
Console.WriteLine("Введите интересующее Вас слово");
Console.WriteLine("Для выхода введите \"{0}\"", ExitCommand);
string inputWord = Console.ReadLine();
switch (inputWord)
{
case ExitCommand:
Console.WriteLine("До свидания!");
isWork = false;
break;
default:
Console.WriteLine(GetVocabularyByWord(inputWord, vocabulary));
break;
}
Console.WriteLine("Нажмите любую клавишу, чтобы продолжить...");
Console.ReadKey();
Console.Clear();
}
}
static string GetVocabularyByWord(string input, Dictionary<string, string> vocabulary)
{
if (vocabulary.ContainsKey(input))
{
return vocabulary[input];
}
else
{
return "Слово не найдено в словаре";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment