Поиск значения по ключу в Dictionary - C#

Узнай цену своей работы

Формулировка задачи:

Как сделать что бы я вводил "ttt", а мне выводила "глицин" и наоборот все варианты?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<string, string> AuthorList = new Dictionary<string, string>();
 
            AuthorList.Add("ggt", "гистидин");
            AuthorList.Add("ggg", "фенилаланин");
            AuthorList.Add("ctg", "глицин");
            AuthorList.Add("ttt", "глицин");
 
            Console.WriteLine("Authors List");
            foreach (KeyValuePair<string, string> author in AuthorList)
            {
                Console.WriteLine("{0}, {1}", author.Key, author.Value);
            }
            Console.ReadKey();
        }
    }
}

Решение задачи: «Поиск значения по ключу в Dictionary»

textual
Листинг программы
static void Main(string[] args)
        {
            Dictionary<string, string> AuthorList = new Dictionary<string, string>();
 
            AuthorList.Add("ggt", "гистидин");
            AuthorList.Add("ggg", "фенилаланин");
            AuthorList.Add("ctg", "глицин");
            AuthorList.Add("ttt", "глицин");
            string value = "";
            if (AuthorList.TryGetValue("ttt", out value))
            {
                Console.WriteLine(value);
            }
            Console.ReadKey();
        }

ИИ для рефератов и докладов


  • Экспорт Word по ГОСТу
  • Минимум 80% уникальности текста
  • Поиск релевантных источников в интернете
  • Готовый документ за 2 минуты

Оцени полезность:

15   голосов , оценка 3.8 из 5
Похожие ответы