Search code examples
listwindows-phone-7generic-listgeneric-collections

what is the alternative method to list.find() in wp7


I have a List<> of objects. I wanted to use the method Find(Predicate match), but i did not find it in wp7.

What can i use in alternative to this method?

thank you for help.


Solution

  • You can use Linq instead. The equivalent of Find in Linq is FirstOrDefault:

    yourList.FirstOrDefault(predicate);
    

    Just make sure you have added using System.Linq; on top of your file, or you won't find the FirstOrDefault method.