Connecting Tech Pros Worldwide Forums | Help | Site Map

IComparer vs IComparable

Fernando Rodríguez
Guest
 
Posts: n/a
#1: Nov 16 '05
Hi,

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

Thanks

James Curran
Guest
 
Posts: n/a
#2: Nov 16 '05

re: IComparer vs IComparable


"Fernando Rodríguez" <fernandoSPAM.YOURSELF@fernando-rodriguez.com> wrote in
message news:t43om05jbtj6j0jpm6vo8c83ugv1t1b18p@4ax.com...[color=blue]
> I don't understand very well the diferences between both. When should each[/color]
be[color=blue]
> used?[/color]

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!)


Closed Thread