📅  最后修改于: 2022-03-11 14:57:37.284000             🧑  作者: Mango
using System;
using System.Collections.Generic;
using System.Linq;
namespace get_dictionary_key_by_value
{
class Program
{
static void Main(string[] args)
{
Dictionary types = new Dictionary()
{
{"1", "one"},
{"2", "two"},
{"3", "three"}
};
string key = "";
foreach(var pair in types)
{
if(pair.Value == "one")
{
key = pair.Key;
}
}
Console.WriteLine(key);
}
}
}