日期:2014-05-20 浏览次数:20938 次
public void serialPort_ReceiveData(object sender, SerialDataReceivedEventArgs e) { string s = ""; byte[] APIcmd = new byte[34]; this.serialPort1.Read(APIcmd, 0, APIcmd.Length); s = System.Text.ASCIIEncoding.ASCII.GetString(APIcmd);//这样处理得到的结果是s="123\0\0\0\0\0\0\0\0\0\0" //for (int i = 0; i < APIcmd.Length; i++) //{ // s += APIcmd[i].ToString(); //}//这样处理的结果是s="495051000000000000" this.textBox1.Invoke(new testTextBox(stringTest), new object[] { s.Trim() }); }