-1
byte b = 0;
foreach (Control x in this.Controls)
{
    if (x is PictureBox)
    {
        x.Tag = saylar[b].ToString();
        b++;
    }
}

I am getting error saying that array was out of bounds, why is that? It works perfectly fine on my friend's C#.

user2943407
  • 409
  • 3
  • 5
  • 13

1 Answers1

2

You are getting the error because saylar[b] is being pointed to an index that is out of the array's bounds.

Put a breakpoint on this line: x.Tag = saylar[b].ToString(); and then watch the result as the code runs.

You haven't shown us what saylar is, but this is your problem.

Hope it helps!

Matt Cashatt
  • 23,490
  • 28
  • 78
  • 111