tags:

views:

47

answers:

1

I am initializing and array of objects, i need something like this:

Greyhound[1].StartingPosition = pictureBox1.Location;
Greyhound[2].StartingPosition = pictureBox2.Location; 

and so on.. but I need to make it by a loop

for ( ......... ) 
      { Greyhound[i].StartingPosition = ????????? // what should go here }
+1  A: 

If this is C# then something like this should work:

int max = 5;
for(int i = 1; i < max; i++) {
   Greyhound[i].StartingPosition =  this.Controls.Find("pictureBox" + i.ToString(), true)[0].Location;
}
Jay