-1

I have this value 10732 I converted this value to ´hexadecimal` like this:

string hex = string.Join(string.Empty, "10732".Select(c => ((int)c).ToString("X")));

And I got as result: 3130373332

But, using the Calculator of W7 in "programmer" mode. When I convert 10732from DECIMAL to HEX,
I got 29EC as result. Why ? How may I do this using C#?

PlayHardGoPro
  • 2,320
  • 7
  • 36
  • 72

1 Answers1

6

You are converting each character in the string to a hex.

Char   Int value (dec)   Hex value
1      49                31
0      48                30
7      55                37
3      51                33
2      50                32

You should be simply converting the int directly:

10732.ToString("X")

If the value is a string, convert to an integer first:

Int.Parse("10732").ToString("X")
Oded
  • 463,167
  • 92
  • 837
  • 979