110,538
社区成员
发帖
与我相关
我的任务
分享
private void btnsend_Click(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(textsend.Text))
{
MessageBox.Show("请先输入待发送内容", "提示");
return;
}
byte[] ss = new byte[textsend.Text.Replace(" ", "").Length / 2];
for (int h = 0; h < ss.Length; h++)
{
ss[h] = Convert.ToByte(textsend.Text.Replace(" ", "").Substring(h * 2, 2), 16);
}
serialPort1.Write(ss, 0, ss.Length);
}
直接从程序里截得,声明数组,然后转化,就这几布,.text你可以直接用你的string数组