For loop that only executes once

I’m having a problem with a for loop that is only executing once:

BuildingCell SelectCellByWeight()
    {
        int highestWeight = 1;
        List<BuildingCell> possibleCells = new List<BuildingCell>();
        for(int x = 0; x < cellMap.GetLength(0); x++)
        {
            for(int y = 0; y < cellMap.GetLength(1); y++)//Only running once.
            {
                Debug.Log("YCell");
                int currentWeight = weightMap[x, y];
                if(currentWeight > highestWeight)
                {
                    possibleCells.Clear();
                    highestWeight = currentWeight;
                    Debug.Log("Clear");
                }
                if(currentWeight == highestWeight)
                {
                    possibleCells.Add(cellMap[x, y]);
                }
            }
        }
        int index = randomGenerator.Next(0, possibleCells.Count);
        return possibleCells[index];
    }

Cellmap is a 2D array of BuildingCells and weightMap is a 2D array of ints. Debug.log on both shows that they have their full size. Is there a problem in this section, or does it have to be somewhere else in the code.

Are you sure you aren’t just hitting an error somewhere within the second for loop? Can you step through each line of that? That’s really the best approach to understanding what’s going on.

weightMap is a 2D array? Any chance it’s null, or that the value of weightMap[×] is null?

Again, I recommend stepping through each line to see where it’s stopping.

Can you outline your declaration code for cellMap - what is this type etc.

If the loop is happening once, then that is where your problem is.
Add a Debug Just before the x loop that Debugs the length of cellmate
And then a debug just inside the for loop; Debug.Log(x);