T
Tony
Hello!
I'm reading in a book and this can't be correct it says.
"Objects passed to Comparer.Compare() are checked to see if they support
IComparable.
If they do, then that implementation is used"
Assume I have a collection of Item(s) in an ArrayList
This class called Item support the IComparable interface which contains the
CompareTo method
so this method is impemented in class Item.
Now I can sort in the way that this CompareTo is implemented.
Now assume I want to be able to sort the collection of item(s) in another
way then this CompareTo is implementet
so I create an helper class which implement the IComparer interface which
contains method Compare.
So not to my question when object of type Item is passed to the Compare
method that implementation
is used of course not the implementation that exist for the IComparable.
//Tony
I'm reading in a book and this can't be correct it says.
"Objects passed to Comparer.Compare() are checked to see if they support
IComparable.
If they do, then that implementation is used"
Assume I have a collection of Item(s) in an ArrayList
This class called Item support the IComparable interface which contains the
CompareTo method
so this method is impemented in class Item.
Now I can sort in the way that this CompareTo is implemented.
Now assume I want to be able to sort the collection of item(s) in another
way then this CompareTo is implementet
so I create an helper class which implement the IComparer interface which
contains method Compare.
So not to my question when object of type Item is passed to the Compare
method that implementation
is used of course not the implementation that exist for the IComparable.
//Tony