Почему выбивает ошибку "Index was outside the bounds of the array"? - C#
Формулировка задачи:
Здравствуйте!
Помогите пожалуйста, не могу понять почему выбивает ошибку "Index was outside the bounds of the array. "
в этой строке И подскажите как исправить?
(floatArr[i]!=0 && floatArr[i - 1]==0)
byte[] buffer = new byte[1024];
float[] floatArr = new float[buffer.Length / 4];
int read = 0;
while (wave.Position < wave.Length)
{
read = wave.Read(buffer, 0, 1024);
for (int i = 0; i < read / 4; i++)
{
if (floatArr[i]!=0 && floatArr[i - 1]==0)
{
int posStart = i;
listBox1.Items.Add(posStart);
}
if (floatArr[i] != 0 && floatArr[i + 1] == 0)
{
int posEnd = i;
listBox2.Items.Add(posEnd);
}Решение задачи: «Почему выбивает ошибку "Index was outside the bounds of the array"?»
textual
Листинг программы
for (int i = 1; i < read / 4 -1; i++)