c# - Removing items in List using LINQ -


This question is already an answer here

  • 14 replies

I type one List is some unit

list

  public class command line {public string productCode; Quantity in public quantities; }  

Items removed from the above list are required if productCode is equivalent to some products.

  list & lt; String & gt; ProductsToBeExcluded = New List & lt; String & gt; () {"1234", "1237"};  

Yes, from to list & lt; Order Line & gt; I need to remove the products which are equal to 1234 and 1237

I have tried

  1. Create from the list; String & gt; from the list & lt; Order Line & gt; Using

      from the list & lt; Order Line & gt; Orderline = gateorder line (); Choose o.ProductCode from order ol = from Orderline;  

2.

  list & lt; String & gt; ProductsToBeExcluded = New List & lt; String & gt; () {"1234", "1237"}; Var filtered = orderline. Skip (Product BackAxWorld);  

I

thanks

In this case you do not need LINQ but just use from the list; T & gt; .RemoveAll instead of

  OrderLines.RemoveAll (X = & gt; ProductsToBeExcluded.Contains (x.ProductCode));  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -