Adding Values to a Byte Array
Posted
by rross
on Stack Overflow
See other posts from Stack Overflow
or by rross
Published on 2010-05-28T14:44:59Z
Indexed on
2010/05/28
15:01 UTC
Read the original article
Hit count: 181
I'm starting with the two values below:
finalString = "38,05,e1,5f,aa,5f,aa,d0";
string[] holder = finalString.Split(',');
I'm looping thru holder like so:
foreach (string item in holder)
{
//concatenate 0x and add the value to a byte array
}
On each iteration I would like to concatenate a 0x to make it a hex value and add it to a byte array.
This is what I want the byte array to be like when I finish the loop:
byte[] c = new byte[]{0x38,0x05,0xe1,0x5f,0xaa,0x5f,0xaa,0xd0};
So far all my attempts have not been successful. Can someone point me in the right direction?
© Stack Overflow or respective owner