Hi,
String.Compare
compares strings, not numbers. The reason you are seeing the -2 and 2 returning 1 is because the language is trying to determine where the numbers fit in terms of sorting them as words. ie if you tried to do
string.Compare("-a", "a");
you will get the same result.
If comparing numbers, they should be converted to numbers. You can try to overload the
Compare
method and using the
StringComparison.Ordinal
as a third parameter and that should fix the problem.
There is more discussion on MSDN
http://msdn.microsoft.com/en-us/library/system.globalization.compareoptions.aspx
Dave