I have a List of type some entity
List
public class OrderLine
{
public string productCode;
public int quantity;
}
如果产品代码与某些产品相同,我需要从上述列表中删除项目。
List<string> ProductsToBeExcluded = new List<string>(){"1234","1237"};
那么,从 List<OrderLine>
中我需要移除等于 1234 和 1237 的产品
我尝试过:
create a
List<string>
fromList<OrderLine>
usingList<OrderLine> OrderLines = GetOrderLines(); var ol = from o in OrderLines select o.ProductCode;
2.
List<string> ProductsToBeExcluded = new List<string>(){"1234","1237"};
var filtered = OrderLines.Except(ProductsToBeExcluded);
如何继续进行删除操作?
谢谢。