IComparer vs IComparable

  • Thread starter Thread starter Fernando Rodríguez
  • Start date Start date
F

Fernando Rodríguez

Hi,

I don't understand very well the diferences between both. When should each be
used?

Thanks
 
Fernando Rodríguez said:
I don't understand very well the diferences between both. When should each be
used?

Generally, IComparable is implemented by the class itself, while
IComparer is implemented by a separate class. If you wanted to sort a
collection both with & without regard to case at different times, you might
create two IComparer helper classes for the class.

--
Truth,
James Curran
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
(note new day job!)
 
Back
Top