Journey

Find and FindAll in generic collections

Cover Image for Find and FindAll in generic collections
Weijie Lin

In .NET 2.0, searching through generic collections such as Arrays and Lists are easier with the new Find and FindAll methods. Both methods accepts a Predicate parameter, which is a delegate to a method. According to MSDN, these methods run in O(n). In situations like searching for item(s) in a collection, I used to write utility functions with simple bubble sort algorithm. This causes code duplication and O(n^2) is just too slow.

Therefore, I wrote couple of test cases to explore these two new methods. Check it out!

TestFixtureSetUp


More Stories

Cover Image for My 2 cents on agile development

My 2 cents on agile development

Weijie Lin