Hello!
I have a class called Item as follows. I use CompareTo to be able to sort an
ArrayList containg Items on heatNumber. This works fine.
Now to my question. I also want to be able to sort a different ArrayList
containg Items on steelGrade. How is that done because I can only have one
CompareTo for the Item class.
class Item : IComparer
{
int heatNumber;
string steelGrade;
public int HeatNumber
{
set { heatNumber = value; }
get { return heatNumber; }
}
public int CompareTo(object right)
{
if (right is Item)
{
Item item = right as Item;
return this.HeatNumber - item.HeatNumber;
}
else
{
throw new ArgumentException("Object to compare is not a Item
object");
}
}
}
//Tony