byte[] fs = new byte[2];
fs[0] = 0x40;
fs[1] = System.Text.Encoding.ASCII.GetBytes(textbox.txt); 这段转换byte出错,无法隐式转换
port.write(fs,0,2);请问这个应该怎么把字符转换成byte发送?
fs[0] = 0x40;
fs[1] = System.Text.Encoding.ASCII.GetBytes(textbox.txt); 这段转换byte出错,无法隐式转换
port.write(fs,0,2);请问这个应该怎么把字符转换成byte发送?
fs[0] = 0x40;
fs[1] = (byte)textbox.txt; //
port.write(fs,0,2);
试试!
byte(C# 参考)
fs[0] = 0x40;
fs[1] = (byte)(char.Parse(textbox.txt));
port.write(fs,0,2);