Compiler Error: Invalid rank specifier: expected',' or ']' on Two Dimensional Array Initialization

The C# compiler thinks you're trying to declare a jagged array, and doing so incorrectly. A jagged array is an array of arrays, where each array contained within the main array can have a different number of elements. A jagged array is declared as follows:

int[][] jaggedArray = new int[numElements][];

Which would create an array that could hold "numElements" arrays of integers within it.

You want to declare a multidimensional array, e.g.:

int[,] grid = new int[g.cols, g.rows];

public int[][] getConvergenceCounts(MandelbrotGrid g){
    int[][] grid=new int[g.cols][];

    for(int x=0;x<g.cols;x++){
     int[x] = new int[g.rows]
     for(int y=0;y<g.rows;y++){
        double tx=x*(double)3/400-1.5;
        double ty=y*(double)3/400-1.5;
        grid[x][y]=getConvergenceCount(new Complex(ty,tx));
     }
  }

  return grid;
}