c# 2D array error: need Help!

public void SetWorldMapOutline()
{

	worldMap = new MapTileData[700, 700];
	for (int y = 0; y < 700; y++)
	{
		axisY = size - y;
		for (int x = 0; x < 700; x++)
		{
		
				
				worldMap[y, x].X = 0;
				
			
		}
	}
}

worldMap[y,x] is null. I do not understand why?

Although you have instantiated an array of [700,700] MapTileData objects, you haven’t instatiated the objects within that array, the following line

worldMap = new MapTileData[700,700]

makes an array for the objects, but doesn’t create the actual objects within it. To fill the array you have to iterate over all the objects and do something along the lines of,

for(int i=0; i<700; i++){
   for(int j=0; j<700; j++){
      worldMap[i,j] = new MapTileData();
   }
}

So what you could have at the end is…

public void SetWorldMapOutline()

{

worldMap = new MapTileData[700, 700];
for (int y = 0; y < 700; y++)
{
    axisY = size - y;
    for (int x = 0; x < 700; x++)
    {

            worldMap[y, x] = new MapTileData();
            worldMap[y, x].X = 0;

    }
}

}

or similar.