两个Dictionary是否存在相同Value用Lambda表达式如何写?求指教
用Intersect(),示例代码如下:
var dict1 = new Dictionary<int, string>
{
{1, "a"},
{2, "b"}
};
var dict2 = new Dictionary<int, string>
{
{1, "b"},
{2, "c"}
};
var isIntersected = dict1.Values.Intersect(dict2.Values).Count() > 0;
Console.WriteLine(isIntersected); //Output is True
dict2.Any(d => dict1.Groupby(t => t.Value).Select(t => t.Key).Contains(d))
大概这样