read line by line the text file for make map in xna

Posted by Mohammadali Najjar khodabakhsh on Stack Overflow See other posts from Stack Overflow or by Mohammadali Najjar khodabakhsh
Published on 2012-09-08T08:54:51Z Indexed on 2012/09/08 9:38 UTC
Read the original article Hit count: 156

Filed under:
|

i want to read a text file for 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.


solve :

Thank you (L.B AND user861114) at last my problem solve like this :

    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]);
        }
    }

thanks alot.

© Stack Overflow or respective owner

Related posts about c#

Related posts about xna-4.0