My problem is, when I want to convert (result[i].JobOrder) to int.I have a string 120100 in (result[i].JobOrder). In return I get not integer but something like “0x0001d524”. And I could not understand why.
for (int i = 0; i < result.Count; i++)
{
if (Convert.ToInt32(result[i].JobOrder) > maxJobOrder)
{
maxJobOrder = Convert.ToInt32(result[i].JobOrder);
}
}
Your code works, but you have set your debugger to display integers in hexadecimal. The value 0x0001d524 is the hexadecimal representation of the integer 120100.
This is not an error in the program, but a configuration option for your IDE. If you use Visual Studio, you can change this setting by pressing the “Hex” button in the “Debug” toolbar.
As an aside, if you are using C# 3 or newer you can simplify your code by using the
Maxmethod to find the maximum instead of looping: