Where Extension Method V/s FindAll


Upon checking on MSDN, the only advantage of FindAll I found is backwards compatibility until .NET 2.0 on the other hand, Where seemed to be introduced in .NET 3.5 … Technically, Where should outperform FindAll for large number of records as despite the observations that on small set, these two would likely perform comparably. The reason is their mechanisms.

FindAll copies the matching elements to a new list, whereas Where just returns a lazily evaluated sequence – no copying is required. That said in the case of “FindAll”, the new List created to contain the results will have to dynamically grow to contain additional results. Memory usage of FindAll will also start to grow exponentially as the number of matching results increases where as … “Where” should have constant minimal memory usage.

Ref : http://stackoverflow.com/a/2260227, http://stackoverflow.com/a/1531756

Advertisements

Published by

Aarsh Talati

Software Developer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s