Re: bytes To Hex

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Tue, 05 Feb 2008 10:04:28 -0800, Analizer1 <dvs_bis@xxxxxxxxxxxxx> wrote:

Hi I have a Long Number
In a Byte[]

Im not sure how to convert this Byte[] array to a Hex
string

Well, the .NET way would be to use BitConverter to get the bytes into an actual long value, and then use ToString("x") to convert to hex:

byte[] rgb = { 1, 2, 3, 4, 5, 6, 7, 8 };
string strHex = BitConverter.ToInt64(rgb, 0).ToString("x");

Pete
.



Relevant Pages

  • Re: Big endian convention in Ruby
    ... if the array holding this is ... messageHex[0].hex.to_i this will ensure that it is a integer in hex. ... Unpack directly to Integers, as shown above. ... It works perfectly fine with in give the loop 64 times.. ...
    (comp.lang.ruby)
  • Re: What does this mean?
    ... well its an array of unsigned char, initialised with a string. ... contains hex values. ... It includes nul characters so you can't ... I'm not sure what you mean by "what does the value of the array ...
    (comp.lang.c)
  • Re: byte data manipulation
    ... Read in the input hex file, stripping of the preamble and checksum ... and putting the bytes (2 chars) into array_1. ... explains why you need the array. ...
    (comp.lang.c)
  • Re: Convert Byte [] to byte
    ... If you want to convert an array of BYTEs, you may use a function like so: ... // Converts a vector of bytes into an hex string. ... If you want to change vector size, ...
    (microsoft.public.vc.mfc)
  • Byte To Hex and back again...
    ... this byte array to Hex. ... becomes a length of 41 and I get an error relating to the length of ... "delete" the last byte of my (hex to byte) array. ... (Const sPassword As String) ...
    (microsoft.public.dotnet.languages.vb)