I am trying to create a world map for a console-based game.
In the World class I have string arrays that can be printed using a level print method.
public static string[] A1 = new string[]
{
(" level data"),
(" level data"),
};
This works if I do
Render.DrawLevel(World.A1);
where Render.DrawLevel takes args:
(string[] _level)
However, in the World Class, I want to create a two-dimensional array that can hold all of the Map's string arrays.
I have tried:
public static string[,][] Map = new string[,][]
{
{ A1 , A2 },
{ B1 , B2 },
};
But if I try to use:
World.Map[0,0]
as my arguments for level printed, I get given an error that this is NULL, instead of the string[] A1.
How can I create a 2d array of arrays, and refer to it properly for string[] arguments?
Thank you very much,
Fin.
EDIT: Incorrectly copied code as 'static void' not just 'static'.
null. Think about what happens when you make an array of strings; the elements of the array will benulluntil you assign them a value, well your case is essentially the same thing. You need to initialize every element ofMap[,]because they will not automatically reference empty arrays as it seems you are expecting.