Can someone explain how the LINQ functions Where(..) and FindAll(..) differ? They both seem to do the same thing…
Can someone explain how the LINQ functions Where(..) and FindAll(..) differ? They both seem
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
FindAll()is a function on theList<T>type, it’s not a LINQ extension method likeWhere. The LINQ extension methods work on any type that implementsIEnumerable, whereasFindAllcan only be used onList<T>instances (or instances of classes that inherit from it, of course).Additionally, they differ in actual purpose.
Wherereturns an instance ofIEnumerablethat is executed on-demand when the object is enumerated.FindAllreturns a newList<T>that contains the requested elements.FindAllis more like callingWhere(...).ToList()on an instance ofIEnumerable.