I want to read a text file in order to build map.
For example I have this map:
0@0000000
0@0000000
0@0000000
000000000
000000000
000000000
000000000
I know I should use this:
StreamReader reader = new StreamReader(Application.StartupPath+@"/TestMap.MMAP");
string line = reader.ReadToEnd();
reader.Close();
Now, for example, I want read line 2 char “@”. how can i do this?
please help me.
Solved:
Thank you (@L.B AND @user861114), at last my problem was solved:
string[,] item = new string[9, 7];
string[] line = File.ReadAllLines(Application.StartupPath + @"/TestMap.MMAP");
for (int j = 0; j < 7; j++)
{
for (int i = 0; i < 9; i++)
{
item[i, j] = line[j].Substring(i, 1);
Console.WriteLine(i + " " + j + "=" + item[i, j]);
}
}
then you can access