I was wondering how can I stop the iteration through the rows and columns of a 2d matrix if a value is found.
int[,] matrix = new int[8, 10];
Random rnd = new Random();
bool value = false;
for (int row = 0; row < matrix.GetLength(0); row++)
{
for (int col = 0; col < matrix.GetLength(1); col++)
{
int number = rnd.Next(1, matrix.Length + 1);
matrix[row, col] = number;
Console.Write("{0,3}", number);
if (number == 8)
{
value = true;
break;
}
}
}