I don't understand what I'm doing wrong but I'm getting this error when trying to loop through this array of picturebox creations. Thus, I've used the try and catch to narrow it down, but still I don't know what's wrong?
private System.Windows.Forms.PictureBox[] imgVictim = new PictureBox[3]; //array for victim images
public void victimsRun()
{
victimTimer.Enabled = true; //starts the timer
PictureBox[] victim = new PictureBox[3];
for (int i = 0; i < imgVictim.Length; i++) // 0 - 2
{
try
{
imgVictim[i].Image = Image.FromFile("victim" + i.ToString() + ".png");
}
catch (NullReferenceException)
{
MessageBox.Show("NULL EXECEPTION!");
}
MessageBox.Show(i.ToString());
}
}
Could anyone at all help me?