大家好,篩選對象清單
我有一個ArrayList PList
中的對象列表。對象看起來像這樣
Product
{
int ProductId,
string ProductDescription,
int StoreId
int supplierid
}
我想產品的非重複組合添加到另一個 陣列
Product[] Parray.
例如:
ArrayList Plist
具有:
productid , productdescription, storeid, supplierid
1, "AB", 11 , 123
2, "CD", 24 ,454
1, "AB", 11 ,431
我想要產品[] Parray有
productid , productdescription, storeid, supplierid
1, "AB", 11 ,123
2, "CD", 24 , 454
我知道,我可以用鍵值對的哈希表,但在這種情況下,我有3個按鍵產品編號,說明& STOREID
這裏是我的代碼截至目前:
private Types.Product[] LoadProducts()
{
ArrayList PList = new ArrayList();
// Business Logic , extracting values from xml using xpath
//Loop though each xml node
for (int j = 0; j < xmlprodlist.Count; j++)
{
//Business logic
PList.Add(call another function here);
}
//What code here ??
Types.Product[] PArray = (Types.Product[])PArrayList.ToArray(typeof(Types.Product));
return PArray;
}
誰能告訴我,我需要的地方什麼代碼在這裏
爲什麼你使用'ArrayList'而不是'名單'? –
Habib