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
-
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
Post a Comment