problem with using CompareTo when having string



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


.



Relevant Pages

  • Re: help me plz
    ... SQL injection attack was the byval num as integer function argument. ... passing in the username as a string instead of the ID. ... > type int, ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: read writte to file
    ... Note that cK is of type int and not char, ... to match the return type of getchar. ... A line is like a string, ... and a string is terminated by a '\0' character. ...
    (comp.lang.c)
  • Re: making sure only integer is input
    ... I have a number guessing game in which users try to guess a random number. ... input is required of type int. ... I know a string is not what we're after but in terms of error-handling; How can we prevent users from entering a string? ... {/* declare a buffer for holding the input line */ ...
    (comp.lang.c)
  • Re: int array to string?
    ... > array of type int? ... > next integer from the array onto the growing string, ... There's no need to 'move' the terminator, ...
    (comp.lang.c)
  • making sure only integer is input
    ... I have a number guessing game in which users try to guess a random number. ... input is required of type int. ... I know a string is not what we're after but in terms of error-handling; ... Implying, that the user is warned about the mistake and prompted again in ...
    (comp.lang.c)