1)函式GetByteArray返回轉換後的位元組陣列,完整程式如下:
class Program
{
static void Main()
string ss = "FE FE FE 68 20";
byte[] bArray = GetByteArray(ss);
foreach (var b in bArray)
Console.Write("{0:X2} ", b);
}
Console.WriteLine();
public static byte[] GetByteArray(string shex)
string[] ssArray = shex.Split(" ");
List
foreach (var s in ssArray)
//將十六進位制的字串轉換成數值
bytList.Add(Convert.ToByte(s, 16));
//返回位元組陣列
return bytList.ToArray();
2)執行結果
1)函式GetByteArray返回轉換後的位元組陣列,完整程式如下:
class Program
{
static void Main()
{
string ss = "FE FE FE 68 20";
byte[] bArray = GetByteArray(ss);
foreach (var b in bArray)
{
Console.Write("{0:X2} ", b);
}
Console.WriteLine();
}
public static byte[] GetByteArray(string shex)
{
string[] ssArray = shex.Split(" ");
List
foreach (var s in ssArray)
{
//將十六進位制的字串轉換成數值
bytList.Add(Convert.ToByte(s, 16));
}
//返回位元組陣列
return bytList.ToArray();
}
}
2)執行結果