public static void MakeAndSendDatagram(byte nGroup, byte nType, byte[] DataByte, TTestSession tSession) { byte[] tempByte = new byte[1 + 1 + 4 + 1 + 1 + DataByte.Length]; Encoding.ASCII.GetBytes("<", 0, 1, tempByte, 0); Encoding.ASCII.GetBytes(">", 0, 1, tempByte, tempByte.Length - 1); byte[] btGroup = { nGroup }; byte[] btType = { nType }; byte[] btLenth = System.BitConverter.GetBytes(tempByte.Length - 2); btLenth.CopyTo(tempByte, 1); btGroup.CopyTo(tempByte, 5); btType.CopyTo(tempByte, 6); DataByte.CopyTo(tempByte, 7); //发送信息 tSession.SendDatagram(tempByte); }