Expression denotes a `type', where a `variable', `value' or `method group' was expected

Hi all, I’ve seen a couple questions with this error. But I am not sure what exactly is going on. I’m pretty sure I have “news” in all the right spots but it just doesn’t want to take it.

I’m using a 2D array (a 9x9 grid) to store a spawn points in a grid for a prefab. I also need to keep track if something is on in the grid, thus I made a custom class:

public class gridSpawn {
 GameObject prefab;
 public bool on;
 Vector3 pos;

 public gridSpawn( GameObject n, Vector3 b ){
  prefab = n;
  pos = b;
 }

 bool toggleOn(){ // toggles on, returns if val of on
  on = !on;
  return on;
 }

 void spawn(){
   GameObject.Instantiate(prefab, pos, Quaternion.identity);
 }
}

I’m setting up the grid in my start function in the main class for the script:

public class SpawnGrid : MonoBehaviour {
 public GameObject pre = new GameObject();
 private gridSpawn[,] grid;
 // Use this for initialization
 void Start () {
 grid = new gridSpawn[9,9];
 for( int i = 0; i < 9; i++ )
 {
 for( int z = 0; z < 9; z++ )
 gridSpawn_[z] = new gridSpawn( pre, new Vector3( i * 20 - 90    , z * -20 + 90, 80 ) );_

}
}

// Update is called once per frame
void Update () {

}
}
The line in question is gridSpawn*[z], I just don’t see what I’m missing. The news are there, but it seems to suggest that pre somehow needs to be “new” yet it’s a member of the class…*
Anyway. I apologize for the formatting, it’s durdling hard.

You use a [multidimensional array][1], but you are trying to access it as a [jagged array][2].

Either change the declaration, or the way you access it:

/// multidimensional array
// declaration
private gridSpawn[,] grid;
// initialization
grid = new gridSpawn[9,9];
// usage
grid [i,j] = something;

/// jagged array
// declaration
private gridSpawn[][] grid;
// initialization
grid = new gridSpawn[9][];
for(int i=0; i<9; i++)
{
    grid *= new int[9];*

}
// usage
grid [j] = something;
Since you now excalty the size of your array, I would recommend the use of a multidimensional array which is faster and memory friendlier.
Note: about that last comment, [multidimensional arrays should be faster than jagged array][3], but CLR implementation on Microsoft .Net is very bad. I don’t know how this is implemented on Mono. But we can hope that this is better done.
_[1]: Microsoft Learn: Build skills that open doors in your career
_
[2]: Microsoft Learn: Build skills that open doors in your career
_*[3]: performance - Why are multi-dimensional arrays in .NET slower than normal arrays? - Stack Overflow