T
Tony
Hello!
I have method CompareTo written below. But I have a problem because I want
to sort on HeatNumber which is of type int and if this is the same on
MspName
which is a string. But according to the compiler I'm not allowed to use < on
string.
So my question is how do I solve this problem. The object Item is stored in
an ArrayList.
public int CompareTo(object right)
{
if (right is Item)
{
Item item = right as Item;
if (this.HeatNumber == item.HeatNumber) // same chargenumber
{
if (this.MspName < item.MspName)
return -1;
else if (this.MspName == item.MspName) // same sop
return 0;
else
return 1;
}
else
{
return this.HeatNumber - item.HeatNumber;
}
}
else
{
throw new ArgumentException("Object to compare is not a Item
object");
}
}
//Tony
I have method CompareTo written below. But I have a problem because I want
to sort on HeatNumber which is of type int and if this is the same on
MspName
which is a string. But according to the compiler I'm not allowed to use < on
string.
So my question is how do I solve this problem. The object Item is stored in
an ArrayList.
public int CompareTo(object right)
{
if (right is Item)
{
Item item = right as Item;
if (this.HeatNumber == item.HeatNumber) // same chargenumber
{
if (this.MspName < item.MspName)
return -1;
else if (this.MspName == item.MspName) // same sop
return 0;
else
return 1;
}
else
{
return this.HeatNumber - item.HeatNumber;
}
}
else
{
throw new ArgumentException("Object to compare is not a Item
object");
}
}
//Tony