Поиск значения по ключу в 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();
}