For a university project I was tasked with creating a crossword game in windows forms using c#, I have 25 textboxes laid out in a grid and named with their indexes(e.g. txtCell00, txtCell01). Image of the form layout with the textbox names and layout
To check the guesses I want to loop through all the cells and compare them to an array of the correct answers, but I don't know how to loop through all the cells without having 25 nested if statements. I wanted to know if there was a way to use string manipulation in the actual code e.g.
for(int i = 0; i <= 4; i++)
{
for(int m = 0; m <= 4; m++){
if(txtCell[i][m].Text == ans[i][m])
{
}
}
}
I am probably being stupid and there is probably a better alternative so I would greatly appreciate any help you could give.