【发布时间】:2016-09-02 05:50:36
【问题描述】:
我正在读取 5 字节数组
ReadData = new byte[5];
bytewaiting = Serialcomport.BytesToRead;
while (bytewaiting > 0)
{
ReadData[i++] = (byte)Serialcomport.ReadByte(); **<--Error: Index was outside the bounds of the array**
bytewaiting = bytewaiting - 1;
}
【问题讨论】:
-
旁注:请仔细阅读minimal reproducible example 指导以改进您未来的问题。
i++在该代码中毫无意义,因为它从未声明或分配任何合理的值。
标签: c# byte bytearray indexoutofboundsexception