Possible Duplicate:
How can I search a generic TList for a record with a certain field value?
I have a collection of
TList<TActivityCategory>
TActivityCategory has a Name property of type string and I want to search the TList using the Name property.
I see BinarySearch in the TList<> but that would require an instance of TActivityCategory. I just want to pass the string for a name.
How would I go about doing this?
When you create the list you can pass in a comparer. There are some comparer classes in the Generics.Defaults unit where you can pass in some anonymous method to compare two elements. They are used for several methods like IndexOf, Contains or Sort.
Example: