The format I need to create/write to the text file is this:
int[,] map = new int[,]
{
{0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,},
{0,0,0,0,0,0,0,0,},
{1,1,1,1,0,0,0,0,},
{0,0,0,1,0,0,0,0,},
{0,0,1,1,0,0,0,0,},
{0,0,0,0,1,1,1,0,},
{0,0,0,0,0,0,0,1,},
};
This is the code I'm using now to create it:
int count = 0;
StreamWriter w = new StreamWriter(@"C:\Temp\test\test.txt");
w.Write("{");
for (int k = 0; k < ret.GetLength(0); k++)
{
for (int l = 0; l < ret.GetLength(1); l++)
{
var val = ret[k, l];
w.Write("," + val);
count++;
if (count == 8)
{
w.Write("},");
w.WriteLine(string.Empty);
w.Write("{");
count = 0;
}
}
}
w.Close();
}
What I get so far in the end in the text file is this:
{,1,1,1,0,0,0,0,0},
{,0,0,1,0,0,0,0,0},
{,0,0,1,1,0,0,1,1},
{,0,0,0,1,0,0,1,0},
{,0,0,1,1,0,0,1,0},
{,0,0,1,0,0,0,1,0},
{,0,0,1,1,1,0,1,0},
{,0,0,0,0,1,1,1,0},
{
It's almost fine but how do I rid/remove the last { ?
The result should be for now:
{,1,1,1,0,0,0,0,0},
{,0,0,1,0,0,0,0,0},
{,0,0,1,1,0,0,1,1},
{,0,0,0,1,0,0,1,0},
{,0,0,1,1,0,0,1,0},
{,0,0,1,0,0,0,1,0},
{,0,0,1,1,1,0,1,0},
{,0,0,0,0,1,1,1,0},
I and then later to add the rest the }; in the end and the rest I will add later.
But first only this part how to remove the last {