字符串拼接

it2022-05-09  17

all = new byte[(by.Length + bytSendArray.Length)*20];

for (i = 0; i < 10; i++ ) { Buffer.BlockCopy(by, 0, all, i*(by.Length + bytSendArray.Length), by.Length); Buffer.BlockCopy(bytSendArray, 0, all, i * (by.Length * sizeof(byte)+by.Length + bytSendArray.Length), bytSendArray.Length); }

 

for (int i = 0; i < 10; i++) { SampRepInfor para = new SampRepInfor(); para.ID = 1; para.Sex = 1; para.Age = 18; para.HCYResult = 9; para.Name = "张敏";

by = BytesToParaHelper.ParaToBytes(para);

}

 

 

//接收 byte[] bytReceiveArray = new byte[bytSendArray.Length]; byte[] tm = new byte[by.Length]; int ReceiveNum = comPort.SendCommand(all, ref bytReceiveArray, 200); SampRepInfor samp = new SampRepInfor();

if (ReceiveNum!=0) { // Array.Copy(源数据, 源数据开始复制处索引, 接收数据, 接收数据开始处索引, 复制多少个数据); for (int i = 0; i < bytReceiveArray.Length; i = i + by.Length) { Array.Copy(bytReceiveArray, i, tm, 0, by.Length); samp = BytesToParaHelper.BytesToPara(tm); Table = ParaToDataTableHelper.ConvertToDataTable(samp, dt);

} }

转载于:https://www.cnblogs.com/MiLu/p/6632427.html


最新回复(0)