以下のコードをLINQまたはLambda式に変換します。Removeメソッドを含む入れ子のForloopとLINQを使用するIf条件
for (int indexprod = 0; indexprod < tempProduct.Count; indexprod++)
{
for (int index = 0; index < tempProduct[indexprod].Prices.Count; index++)
{
if (tempProduct[indexprod].Prices[index].Term == null || tempProduct[indexprod].Prices[index].Term == 0)
{
tempProduct[indexprod].Prices.Remove(tempProduct[indexprod].Prices[index]);
index--;
}
}
if (tempProduct[indexprod].Prices.Count == 0)
{
tempProduct.Remove(tempProduct[indexprod]);
indexprod--;
}
}
ASAPが必要です。
私はこれを実行しようとしました:
List<Product> tempprod1= (from p in products
from pr in p.Prices
where pr.Term == 0
select p).ToList<Product>();
ではなく、価格要素pr.Termを削除する方法を見つけ出すことができ0!。ここで
おかげで、
を持っているすべての製品を削除する必要があり、機能しません。私は見ることができません。 –