eLisHa <eLisHa@discussions.microsoft.com> wrote:[color=blue]
> Thanks again for replying... but i still dont get the point.
> I have this class - Discount, which exists in my ArrayList dynamic times.
> I want to sort the ArrayList, so i understood from you that i need to create
> a IComparer to do that, an IComparer for each field to sort by.[/color]
Yes.
[color=blue]
> Now - i dont understand how to do that - creating the IComparer for sorting
> by.
> I looked in .net sdk, and IComparer doesnt have a constructor (v1.1). It
> just has one member, a method - Compare.
>
> How do i create a new instance of it (for instance - DiscountIDComparer),
> that will know to compare the DiscountID's?[/color]
It's an interface. You need to implement the interface yourself:
public class DiscountIDComparer : IComparer
{
public int Compare (object first, object second)
{
// Compare first and second - they should both
// be references to Discount instances.
// See the docs for more information
}
}
If you haven't used interfaces before, now would be a very good time to
put your project down temporarily and learn about them before you
continue. They're very, very important.
--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too