Trying to write a string to multi dimensional int map.
1,1,1,1,1,1,1,1,1,1,1
1,0,0,0,0,0,0,0,0,0,1
1,0,0,0,0,0,0,0,0,0,1
1,0,0,0,0,0,0,0,0,0,1
1,1,1,1,1,1,1,1,1,1,1
Yeah you can pretty much guess what that's for. A collision map. But anyways, this info is store din a file. Now I got the file in, converted and blah blah. I'll just show the code and show where im having the problem, probably easier that way:
// Convert a string to multi-dim int array,
// format: 1,1,1,1|1,0,0,1|1,1,1,1|
private int[,] ConvertToMapArray(String data)
{
// Split to iterate rows and get row count.
string[] rows = data.Split('|');
// Initialize return data.
int[,] ret;
// Set row count to 0, increment each loop.
int rc = 0;
foreach (string row in rows)
{
// Split each number and iterate. Convert to int32 and and store in its own int array.
string[] items = row.Split(',');
// Initialize int array with proper row count.
int[] newRow = new int[ items.Count() ];
// Count set to 0 for foreach iteration, must increment.
int ic = 0;
foreach (string item in items )
{
// Convert string to int.
int i int.Parse(item);
// Add to newRow int array.
newRow[ic++] = i;
}
// Add new int row to return multi-dim array.
ret[rc++] = newRow; /// <--- this doesnt work
}
return ret;
}