I'm trying to get my program to check if my 2d array has 3 of the same value next to each other.
I currently have this code, but it is returning true whenever I get to count == 2 (sorry that its in dutch):
bool ScoreRijAanwezig(RegularCandies[,] speelveld)
{
bool rij = false;
int count = 0;
` for (int i = 0; i < speelveld.GetLength(0); i++)
{
{
for (int j = 0; j < speelveld.GetLength(1) - 2; j++)
{
if (speelveld[i, j] == speelveld[i, j + 1])
{
count++;
if (speelveld[i, j + 1] == speelveld[i, j + 2])
count++;
if (count >= 3)
{
rij = true;
count = 0;
}
}
}
}
}
return rij;
}
How do I get it that it only returns true whenever the count hits 3 or bigger.