I can't find any FindAll method in my List, how can i select objects from the List that respond to a specific criteria, without using the old iterating method?
List<oPage> mylist = new List<oPage>();
my oPage class has a property called Title of type string.
I added a few items of oPage inside myList.
now i want to select all items inside mylist that have a title containing the word 'abc' 开发者_StackOverflowand return all those items in a IEnumerable.
how is it possible?
Thanks for your help.
If you're using .NET 3.5 or later, you can use LINQ to do just that
mylist.Where(p => p.Title.Contains("abc"));
The FindAll method returns a List, but you can just cast the results to an IEnumerable<oPage>:
List<oPage> mylist = GetYourList();
IEnumerable<oPage> results = (IEnumerable<oPage>)myList.FindAll(
   delegate(oPage p)
   {
      return p.Title.Contains("abc");
   }
);
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论