Matthew Lugg

Matthew Lugg

  • NA
  • 7
  • 2.4k

IndexOutOfRangeException while retriving data from array?

Aug 30 2013 12:19 PM

Hi!

In a C# DLL, I have a for loop that retrieves data from an array named numbers. However, when the code to retrieve it runs, I get an IndexOutOfRangeException.

The exception says:

"An unhandled exception of type 'System.IndexOutOfRangeException' occurred in ClassLibrary1.dll

Additional information: Index was outside the bounds of the array."

The code is:


for(int i = 0; i <= numbers.Length - 1; i++)

{

        where.Text += numbers[i].ToString() + " /r/n ";

}


I apologise if it is something obvious - I am a beginner.

Many thanks.


Answers (6)