static String input = "0102030405060708090a0b0c0d0e0f";
public static void Main()
byte[] data = StringToByteArray(input);
for (int i = 0; i < input.Length; i += 2) {
Console.Write("0x{0}{1}, ", input[i], input[i + 1]);
public static byte[] StringToByteArray(string hex) {
return Enumerable.Range(0, hex.Length)
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))