Find and FindAll in generic collections
![](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fxaku7csq%2Fproduction%2F5e66632214ac076b4aa22458ef3e0a743b71acc2-2798x2798.jpg%3Fw%3D96%26h%3D96%26fit%3Dcrop%26auto%3Dformat&w=256&q=75)
Weijie Lin
![Cover Image for Find and FindAll in generic collections](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fxaku7csq%2Fproduction%2F80c0b0e0fd102044b0a4c08b99597cf27b47c2fb-3999x2666.jpg%3Frect%3D0%2C333%2C3999%2C2000%26w%3D2000%26h%3D1000%26fit%3Dmax%26auto%3Dformat&w=3840&q=75)
![](/_next/image?url=https%3A%2F%2Fcdn.sanity.io%2Fimages%2Fxaku7csq%2Fproduction%2F5e66632214ac076b4aa22458ef3e0a743b71acc2-2798x2798.jpg%3Fw%3D96%26h%3D96%26fit%3Dcrop%26auto%3Dformat&w=256&q=75)
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