少し問題があります。156、340(またはの場合)などに番号を追加してからArrayList
、156、340(の場合)のように番号を削除します。次の解決策は問題なく機能します。私が抱えている問題は、一部の古いデータでは、従業員が500 + 400 + 100+500ではなく1500のような合計を入力していたことです。Sell / TransferOutがあり、ArrayList内に一致するものがない場合に、そのArrayListから複数の項目を追加し、結合して集合体になる要素を見つけるように変更するにはどうすればよいですか。TransferIn
Buy
TransferOut
Sell
ArrayList alNew = new ArrayList();
ArrayList alNewPoIle = new ArrayList();
ArrayList alNewCo = new ArrayList();
string tempAkcjeCzynnosc = (string) alInstrumentCzynnoscBezNumerow[i];
string tempAkcjeInId = (string) alInstrumentNazwaBezNumerow[i];
decimal varAkcjeCena = (decimal) alInstrumentCenaBezNumerow[i];
decimal varAkcjeIlosc = (decimal) alInstrumentIloscBezNumerow[i];
int index;
switch (tempAkcjeCzynnosc) {
case "Sell":
case "TransferOut":
index = alNew.IndexOf(varAkcjeIlosc);
if (index != -1) {
alNew.RemoveAt(index);
alNewPoIle.RemoveAt(index);
alNewCo.RemoveAt(index);
} else {
// Number without match encountred
}
break;
case "Buy":
case "TransferIn":
alNew.Add(varAkcjeIlosc);
alNewPoIle.Add(varAkcjeCena);
alNewCo.Add(tempAkcjeInId);
break;
}
}