代码如下:
/// <summary>
/// 去除byte数组头尾杂质(即不需要的数据)
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
//---------------------去除头杂质---------------------------------
byte[] listTemp = new byte[]
{
1, 2, 3, 4, 5, 6, 7, 8, 0x55, 0xaa, 6, 6, 6, 6, 6, 6, 6, 7, 7,
7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,7,8,8,
1, 4, 3, 2, 4, 6, 7, 8, 9, 2, 1, 0x55, 0xaa, 1, 2, 3, 4, 6 ,2
};
int index = 0;
while (true)
{
if (listTemp[index] != 0x55 && listTemp[index++] != 0xaa)
index++;
else break;
}
byte[] listNew = new byte[listTemp.Length - index];
Array.Copy(listTemp, inde