How to covert Int64 to Hex

T

Tim Sprout

To convert hex to Int64 I can use:

string hex = "413208A97245F5AE";
Int64 intFromHex = System.Convert.ToInt64(hex, 16);
//intFromHex = 4697826885160531374

How do I reverse this, and convert Int64 to hex?

Thanks,

Tim Sprout
 
N

Nicholas Paldino [.NET/C# MVP]

Tim,

You would use the ToString method on the Int64 (or Int32 method if you
want) and specify X or x for the format string (X gives you upper case
letters in the hex string, while x gives you lower case letters).
 
T

Tim Sprout

Thank you, Nicholas.

-Tim Sprout

Nicholas Paldino wrote:
Tim,

You would use the ToString method on the Int64 (or Int32 method if you
want) and specify X or x for the format string (X gives you upper case
letters in the hex string, while x gives you lower case letters).


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)
Tim Sprout wrote:

To convert hex to Int64 I can use:

string hex = "413208A97245F5AE";
Int64 intFromHex = System.Convert.ToInt64(hex, 16); //intFromHex =
4697826885160531374

How do I reverse this, and convert Int64 to hex?

Thanks,

Tim Sprout
 
P

Pedro Luna Montalvo

string hex = "413208A97245F5AE";
Int64 intFromHex = System.Convert.ToInt64(hex, 16);

// another solution...
string backToHex = Convert.ToString(intFromHex, 16);


Pedro Luna, Gye, Ecu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top