Hi. I have an ArrayList of custom objects that have the following properties:
FileName
FilePath
CurrentFolder
TopLevelFolder
I then need to do a BinarySearch (or some other quick search) on the FileName property on all the objects in the ArrayList in .NET. In other words, I need to find the object in the ArrayList with the same FileName as the one I'm searching on.
Syntax for the ArrayList's BinarySearch is this; but how do you do this for an object's property in the arraylist?
public static void FindMyObject( ArrayList myList, Object myObject ) {
int myIndex=myList.BinarySearch( myObject );
if ( myIndex < 0 )
Console.WriteLine( "The object to search for ({0}) is not found. The next larger object is at index {1}.", myObject, ~myIndex );
else
Console.WriteLine( "The object to search for ({0}) is at index {1}.", myObject, myIndex );
}