cnd
cnd

Reputation: 33754

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 ^_)

Upvotes: 1

Views: 555

Answers (2)

Marc Gravell
Marc Gravell

Reputation: 1062770

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.

Upvotes: 1

Bobby
Bobby

Reputation: 11576

offset = System.Convert.ToInt64(this.yourTextBox.Text, 16);

Are you sure you need an Int64 (Long) and not just an Int32 (Int)? If you're a VB6 coder, Int32 (Int) is what you're looking for, not Long.

Upvotes: 1

Related Questions