1

ソートリストが2つあります

 1. oldlist<int,int> 

 2. newlist <int,int>

(アプリケーション固有の情報-キーはindustryId、値は重み)

リストの変更点を比較したいと思います。

私は次のものが欲しい-

  • 重みがゼロではなく、新しいリストではゼロであるアイテムのリスト。

  • 重みがゼロではなく、oldlistから変更されたアイテムのリスト。

比較者と呼ばれるものがあることを私は知っています。ここで使用できますか?

4

1 に答える 1

3

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 };
于 2012-07-26T16:29:59.823 に答える