私はArrayListの2つの配列を持っています。C#:カスタムクラスの2つのArrayListを比較し、重複を見つける
public class ProductDetails
{
public string id;
public string description;
public float rate;
}
ArrayList products1 = new ArrayList();
ArrayList products2 = new ArrayList();
ArrayList duplicateProducts = new ArrayList();
は今、何をしたいすべての製品(ProductDetailsクラスのすべてのフィールドとは)products1
とproducts2
の両方に重複した説明を持つことです。
Iは、従来の方法のような2つのために/ whileループを実行することができ、私はに両方のアレイを10Kを超える要素を有するであろう場合には、特に非常に遅いであろう。
おそらく何かがLINQで実行できます。
'List'を使用し、 'ArrayList'では使用しません。 –
SLaks
おそらくデータベースを使うべきです。 – SLaks
私は@SLaksに同意します。これは、Outter SelectでSubQueryを使用する方がはるかに簡単です。Select Distinctを選択し、Count with Count(*)> = 2を使用してグループを内部で選択します。 – MethodMan