(urgent) Binary data to byte[] array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have the following binary data:

0x800006000000

which is equivalent to the followin

byte[] bytes = new byte[6];
bytes[0] = 0x80;
bytes[1] = 0x00;
bytes[2] = 0x06;
bytes[3] = 0x00;
bytes[4] = 0x00;
bytes[5] = 0x00;

How can I parse the binary to the quivalent byte array?

Thanks,

Yama
 
Yama said:
I have the following binary data:

0x800006000000

As what?
which is equivalent to the followin

byte[] bytes = new byte[6];
bytes[0] = 0x80;
bytes[1] = 0x00;
bytes[2] = 0x06;
bytes[3] = 0x00;
bytes[4] = 0x00;
bytes[5] = 0x00;

How can I parse the binary to the quivalent byte array?

It would help if you could give more details. When you say you have the
data, what format do you have it in? A long? A string?
 
800006000000 = string

Jon Skeet said:
Yama said:
I have the following binary data:

0x800006000000

As what?
which is equivalent to the followin

byte[] bytes = new byte[6];
bytes[0] = 0x80;
bytes[1] = 0x00;
bytes[2] = 0x06;
bytes[3] = 0x00;
bytes[4] = 0x00;
bytes[5] = 0x00;

How can I parse the binary to the quivalent byte array?

It would help if you could give more details. When you say you have the
data, what format do you have it in? A long? A string?
 
800006000000 = string

Jon Skeet said:
Yama said:
I have the following binary data:

0x800006000000

As what?
which is equivalent to the followin

byte[] bytes = new byte[6];
bytes[0] = 0x80;
bytes[1] = 0x00;
bytes[2] = 0x06;
bytes[3] = 0x00;
bytes[4] = 0x00;
bytes[5] = 0x00;

How can I parse the binary to the quivalent byte array?

It would help if you could give more details. When you say you have the
data, what format do you have it in? A long? A string?
 
Yama said:
Hi,

I have the following binary data:

0x800006000000

which is equivalent to the followin

byte[] bytes = new byte[6];
bytes[0] = 0x80;
bytes[1] = 0x00;
bytes[2] = 0x06;
bytes[3] = 0x00;
bytes[4] = 0x00;
bytes[5] = 0x00;

How can I parse the binary to the quivalent byte array?

Thanks,

Yama

String s = "800006000000";
long n = Int64.Parse(s);

byte[] a = new byte[8];
int s, i;
for (i = 0, s = 56; i < 8; i++, s -= 8)
a = (byte)(0xFF & (n >> s));
 

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

Back
Top