-6

do not be tired I defined a 1000-element presentation in the Windows application form space and used it in various areas of the program, but unfortunately I encounter the following error. Thank you for your help: enter image description here

I have defined this variable as follows : enter image description here

Matin
  • 1

1 Answers1

1

Indexes in arrays start with 0. So array with 1000 elements will have indexes from 0 to 999. It throws at the 1000th index. As a solution, you can change your loop to have following condition: i < 1000 instead.

David Oganov
  • 976
  • 1
  • 11
  • 23
  • I changed the code as follows but I still get the error: for (int i = 0; i <1000; i ++) { bloor1 [i] = new TextBox (); bloor2 [i] = new TextBox (); } – Matin Aug 25 '21 at 12:22