2 tonygraycc TonyGraycc 于 2016.09.20 16:25 提问

C# 语句 请教~!!! 下面的 用中文表达的语句块 怎么用代码表示~!!!
        this.Invoke((EventHandler)(delegate
        {
            if (isOpen1)
            {
                var str = System.Text.Encoding.Default.GetString(buffer1);
                this.tbxRecvData.Text += sp1.ReadLine()+"\r\n";
            }
            else
            {
                Byte[] ReceivedData = new Byte[sp1.BytesToRead];
                sp1.Read(ReceivedData, 0, ReceivedData.Length); 
                string RecvDataText = null;
                for (int i = 0; i < ReceivedData.Length - 1; i++)
                {
                    RecvDataText += ("0x" + ReceivedData[i].ToString("X2") + "");
                }
                tbxRecvData.Text += RecvDataText;
            }
        }));
        if (isOpen2)
        {
            try
            {
                sp2.WriteLine("OneEquipment:" + tbxRecvData.Text);
            }
            catch (Exception)
            {
                MessageBox.Show("发送数据时发生错误", "错误提示~!");
                return;
            }
           else
                        {
                        //当tbxRecvData.Text 有数据时 换行 再发送
                        }
        }

                    请问  //中 中文代码怎么写  
                    谢谢了~!!!

1个回答

qq_26625037
qq_26625037   2016.09.20 16:51

if (isOpen2)
{

    }  else
        {
          //当tbxRecvData.Text 有数据时 换行 再发送
                        tbxRecvData.Text="\n"+tbxRecvData.Text;
         }
                     try
        {
            sp2.WriteLine("OneEquipment:" + tbxRecvData.Text);
        }
        catch (Exception)
        {
            MessageBox.Show("发送数据时发生错误", "错误提示~!");
            return;
        }

Csdn user default icon
上传中...
上传图片
插入图片