Search code examples
c#offsetnemerle

Offset as hex from textbox


I'm using lpBaseAddress : IntPtr

but ... I need to enter hex value :-/ like a normal offset

like on VB that could be something like :

offset = CLng("&H" + text)

So I need to take a value from textbox and make same magic on C# (or Nemerle ^_)


Solution

  • If you just want to parse hex:

    string hex = "0a12cc";
    long ptr = Convert.ToInt64(hex, 16);
    IntPtr newPtr = new IntPtr(ptr);
    

    I've used long here for illustration, as IntPtr could be 32/64.