【发布时间】:2013-06-24 15:33:09
【问题描述】:
我有以下代码从Dictionary<int, string> buttonGroups返回项目
其中值与某个字符串匹配。
public static void RemoveColorRange(List<Button> buttons, int[] matches)
{
Dictionary<int, string> buttonGroups = new Dictionary<int, string>();
foreach (Button btn in buttons)
{
if ((int)btn.Tag == matches[0] || (int)btn.Tag == matches[1])
continue;
SolidColorBrush brush = (SolidColorBrush)btn.Background;
Color color = new Color();
color = brush.Color;
buttonGroups.Add((int)btn.Tag, closestColor(color));
}
var buttonMatches = buttonGroups.Where(x => x.Value == 'somestring');
}
但是它返回以下类型而不是字典对象。我似乎无法从 buttonMatches 中检索任何值。我错过了什么?
{System.Linq.Enumerable.WhereEnumerableIterator<System.Collections.Generic.KeyValuePair<int,string>>}
【问题讨论】:
标签: c# linq dictionary