0

私は以下のコードを書きましたが、エラーがあります:インデックスは配列の範囲外でした。

    int bytes = serialPort1.BytesToRead;
        int r = 0;
        byte[] byte_buffer = new byte[bytes];
        serialPort1.Read(byte_buffer, 0, bytes);
           int  x = 0;
            while ((byte_buffer[x] == 0)&(x<230400))
            {
                r++;
                x++;
            }

            byte[] byte_mdfy = new byte[bytes-r];        

どうすればコードを修正できますか?

4

1 に答える 1