开发者_如何学编程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 }
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;
}
精彩评论