A
Arjen
Hi,
I have a class with some attributes. For example class person with name as
attribute.
I have add multiple persons in an arraylist.
Now I need a function to get/find a person by the name attribute. This
function returns the index or the object.
I can do this with a foreach statement. I think there are better solutions,
like the binarysearch function inside the arraylist. The problem is that it
can only search persons by objectkey. I need to search by the attribute of
that object.
Can somebody tell me how to do this with a good example?
I found things (google) about IComparer... but I don't understand these
sample's and I don't get is to work.
After that I also want to sort the persons inside the arraylist by an
attribute.
How does this work?
Many thanks!!!
Arjen
I have a class with some attributes. For example class person with name as
attribute.
I have add multiple persons in an arraylist.
Now I need a function to get/find a person by the name attribute. This
function returns the index or the object.
I can do this with a foreach statement. I think there are better solutions,
like the binarysearch function inside the arraylist. The problem is that it
can only search persons by objectkey. I need to search by the attribute of
that object.
Can somebody tell me how to do this with a good example?
I found things (google) about IComparer... but I don't understand these
sample's and I don't get is to work.
After that I also want to sort the persons inside the arraylist by an
attribute.
How does this work?
Many thanks!!!
Arjen