.Net 8-bit Encoding

后端 未结 5 2108
春和景丽
春和景丽 2020-12-19 13:14

I\'m working on serial port, transmitting and receiving data to some hardware at 8bit data. I would like to store it as string to facilitate comparison, and preset data are

5条回答
  •  無奈伤痛
    2020-12-19 13:29

    I think you should use a byte array instead. For comparison you can use some method like this:

    static bool CompareRange(byte[] a, byte[] b, int index, int count)
    {
        bool res = true;
        for(int i = index; i < index + count; i++)
        {
            res &= a[i] == b[i];
        }
        return res;
    }
    

提交回复
热议问题