c# - How to use .RemoveAll in here? -


Here's a simple question, but it is trying to work on this work ...

< P> I have a class, which is called classification . I have a property called WebName , I want to get a list of classification classes, and want to use . Remove all WebName.ToLower () or "n / a" or "Other" to remove any classification. With the list within WebName is the property type string.

This is what I have tried to do so far:

  list & lt; Classification & gt; The NewsBirds = New List & lt; Classification & gt; (); Classification around = Gaticach niibbertechnikon (); // Returns the parental classification = neighborhood = one city. children. List (); // This gives me a list of classification classes  

How can I change the "code" Only select values ​​that are not "non / single" or " Are not "in each webname property in the classification ?

  theNighborhoods = aNeighborhood.Children.ToList (). Remove All (a => a.WebName.ToLower () == "n / a" || a.WebName.ToLower () == "Other"). ToList ();   

The above code gives me an error, there is no extension like int toList how to do it with . RemovalAll ?

You can do one of the two things. First you can use LINQ from:

  theNighborhoods = aNeighborhood.Children.Where (a => a.WebName.ToLower ()! = "N / A" & amp; ; A .WebName.ToLower ()! = "Other"). ToList ();  

Alternatively, you can call RemoveAll after receiving the list, such as:

  theNighborhoods = aNeighborhood.Children.ToList (); The Nivebooose Rev. L (A = & gt; A. WebName.toolover () == "N / A" || A. WebName to lower () == "Other"). ToList (); Remove  

Remove now gives an int that indicates how many items were removed. This is the reason that you got the error that you encountered I suggest viewing the documentation at RemoveAll.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -