BuiltIn Function to Convert from Hex String to Byte
Posted
by Ngu Soon Hui
on Stack Overflow
See other posts from Stack Overflow
or by Ngu Soon Hui
Published on 2010-03-23T08:18:35Z
Indexed on
2010/03/23
8:23 UTC
Read the original article
Hit count: 310
c#
This question is similar to the one here.
One can easily convert from hex string to byte via the following formula:
public static byte[] HexStringToBytes(string hex)
{
byte[] data = new byte[hex.Length /2];
int j = 0;
for (int i = 0; i < hex.Length; i+=2)
{
data[ j ] = Convert.ToByte(hex.Substring(i, 2), 16);
++j;
}
return data;
}
But is there a built-in function ( inside .net framework) for this?
© Stack Overflow or respective owner