J
Jeff B.
Hello,
I'm trying to optimize some code for converting a delimited string into an
array of bytes. An example of the string to be converted is:
"2b,2c,2d,2e,2f,30,31,32,33,34,35,36,37,38,39,3a,3b"
Where each element is a hex number, separated by a comma, that should be
converted into a byte array. Here is a code snippet that I quickly put
together and am using currently:
<begin snippet>
string[] numbers = valueLine.Split(',');
byte[] bytes = new byte[numbers.Length];
int index = 0;
foreach(string item in numbers)
{
bytes[index] = byte.Parse(item,
System.Globalization.NumberStyles.HexNumber);
index++;
}
<end snippet>
Does anyone know of a quicker way to get the delimited string into a byte
array? I'm looking for the quickest algorithm and not necessarily the
shortest amount of code.
--- Thanks, Jeff
--
Jeff Bramwell
Digerati Technologies, LLC
www.digeratitech.com
Manage Multiple Network Configurations with Select-a-Net
www.select-a-net.com
I'm trying to optimize some code for converting a delimited string into an
array of bytes. An example of the string to be converted is:
"2b,2c,2d,2e,2f,30,31,32,33,34,35,36,37,38,39,3a,3b"
Where each element is a hex number, separated by a comma, that should be
converted into a byte array. Here is a code snippet that I quickly put
together and am using currently:
<begin snippet>
string[] numbers = valueLine.Split(',');
byte[] bytes = new byte[numbers.Length];
int index = 0;
foreach(string item in numbers)
{
bytes[index] = byte.Parse(item,
System.Globalization.NumberStyles.HexNumber);
index++;
}
<end snippet>
Does anyone know of a quicker way to get the delimited string into a byte
array? I'm looking for the quickest algorithm and not necessarily the
shortest amount of code.
--- Thanks, Jeff
--
Jeff Bramwell
Digerati Technologies, LLC
www.digeratitech.com
Manage Multiple Network Configurations with Select-a-Net
www.select-a-net.com