我有两个分类列表
1. oldlist<int,int>
2. newlist <int,int>(特定于应用程序的信息-键是industryId,值是权重)
我想比较一下列表中的变化。
我想要以下的东西-
我知道有一种叫比较器的东西。这里能用吗?
发布于 2012-07-26 16:29:59
您可以使用Linq:
// list of items where weight was not zero, but its zero in the newlist.
var result1 = from o in oldList
join n in newList on o.Key equals n.Key
where o.Value != 0 && n.Value == 0
select new {Old = o, New = n};
// list of items where weight is not zero and has changed from oldlist.
var result2 = from o in oldList
join n in newList on o.Key equals n.Key
where o.Value != 0 && o.Value != n.Value
select new { Old = o, New = n };https://stackoverflow.com/questions/11673734
复制相似问题