日期:2014-05-20  浏览次数:20853 次

求2个Dictionary之间的差集问题。
else if(dicEPC.Count > dictionary.Count)
                    {
                        var listEPC = dictionary.Except(dicEPC).ToDictionary(p => p.Key);
                        if (listEPC.Count > 0)
                        {
                            foreach (var item in listEPC)
                            {
                                lvEPC.Visible = true;
                                lvItem = new ListViewItem();
                                lvItem.SubItems.Add(item.Key);
                                lvEPC.Items.Add(lvItem);
                            }
                        }
                    }

这是源代码,dicEPC是第一次循环读取商品的时候存在这个里面的。dictionary是后面读取的商品存在这个里面的。 求这2个dictionary之间的差集。listEPC 取出来的数据始终不对。求大神指教。在线等。

------解决方案--------------------
哪里不对? 上一下测试数据和期望结果,清楚描述一下你的问题
------解决方案--------------------
dictionary的key value是什么类型的。
如果不是值类型,不能直接用except