The hangman game I'm trying to make throws "ArgumentOutOfRangeException" at the for loop when I'm trying to display the underlines. I tried rewriting the code but nothing worked.
List<Label> underline;
int left = 300;
int top = 275;
for (int i = 0; i < data.solution.Length; i++) //data is the object that contains the word that is the solution
{
underline = new List<Label>();
underline[i].Parent = this;
underline[i].Text = "_";
underline[i].Size = new Size(35, 35);
underline[i].Location = new Point(left, top);
left += 30;
underline[i].Font = new Font(new FontFamily("Microsoft Sans Serif"), 20, FontStyle.Bold);
}
I don't understand what is wrong with this. It throws it right away when I click on new game.