private byte[] GetValidByte()//获取发送的字节流
{
string[] strHEX = richTextBox_Send_1.Text.Split(" ".ToCharArray());
byte[] byteData = new byte[strHEX.Length];
try
{
for (int i = 0; i < strHEX.Length; i++)
{
byteData[i] = byte.Parse(strHEX[i], System.Globalization.NumberStyles.HexNumber);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return byteData;
}
C#中从文本转换为十六进制字节
1万+

被折叠的 条评论
为什么被折叠?



