【发布时间】:2015-10-21 06:50:04
【问题描述】:
我试图从字典中检索特定的一对,并将这对转换为字符串,如下所示:
Dictionary<string, string> testDictionary= new Dictionary<string, string>();
testDictionary.Add("3123", "1");
testDictionary.Add("3523", "2");
testDictionary.Add("5532", "1");
string memberId="5532";
string finalSelectedValue = testDictionary.Where(x => x.Key == memberId).Select(y => y.Key + "_" + y.Value).ToString();
Console.WriteLine(finalSelectedValue);
但是,我不知道如何实现在字典中组合这个特定对的键和值的最后一步。
预期结果是:“5532_1”
【问题讨论】:
标签: c# dictionary