i am using visual studio c# win form. . . i have 2d array of textboxes and i have another 2d array of valid solved sudoku i want to compare textbox’s text to sudoku array but its not working.Here is my code:
private void Isvalid()
{
for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++)
if (copy[i, j] == textbox[i, j].Text)
isvalid = true;
}
private void check()
{
Isvalid();
if (isvalid)
MessageBox.Show("NO");
else
MessageBox.Show("YES");
}
Can anyone plz help me. . .
THANx in Advance. . .
Thanx to all who answerd. . .
You do not (re)set the
isvalidvariable to false, if the arrays are not equal.You pass the result of the
Isvalidmethod through a shared variable. Your code will be much clearer if you pass the result of the comparison as the method result.Now you can test for:
Even better will be if you pass the two arrays as arguments.