-3

I'm currently making a program which saves a bunch of memory addresses to a class automatically. However,

Convert.ToInt32(value)

doesn't seem to want to accept the string value "0xB24C" as a valid integer.

'Input string was not in a correct format.'

Actually I'm able to just save offsets as integers like this public const Int32 m_ArmorValue = 0xB24C;

Here's my code where I assign the integer;

hazedumper.netvars.m_ArmorValue = Convert.ToInt32(value);

value being the string offset "0xB24C"

Can anyone tell me why this error is occurring or is it not possible to convert a string memory address/hexadecimal value to an Int32.

Arslan Ali
  • 420
  • 4
  • 12
siroot
  • 123
  • 1
  • 8

1 Answers1

0

Convert.ToInt32() takes the base as second parameter. Furthermore you must remove the 0x prefix. See the docs for details

var s="0xA123";
var i = Convert.ToInt32(s.Substring(2), 16);
derpirscher
  • 6,458
  • 3
  • 9
  • 25