using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace WIDESEA_Comm.DataHandle { public class OperateDB { /// /// 批量写入西门子字符串 /// /// 源数据 /// 起始下标 /// 写入字符串 public static void WriteData(byte[] sorce, int index, string str) { byte[] data = Encoding.ASCII.GetBytes(" " + str); data[0] = 20;//定义的字符串长度 data[1] = (byte)str.Length;//有效的个数 for (int i = 0; i < data.Length; i++) { sorce[i + index] = data[i]; } } /// /// 直接写入字节数组 /// /// 源数据 /// 起始下标 /// 新增数据 public static void WriteData(byte[] sorce, int index, byte[] data) { for (int i = 0; i < data.Length; i++) { sorce[i + index] = data[i]; } } /// /// 写入字节 /// /// /// /// public static void WriteData(byte[] sorce, int index, byte data) { sorce[index] = data; } } }