StreamReader .Read error counted as int when the text file is string

21 views Asked by At
static void Main(string[] args)
        {
            StreamReader blobread = new StreamReader("input.txt");
            int height = int.Parse(blobread.ReadLine());
            int width = int.Parse(blobread.ReadLine());
            char[,] globs = new char[width, height];
            for (int i = 0; i<width; i++)
            {

                for (int j = 0; j < height; j++)
                {
                    globs[i, j] = blobread.Read();
                }
            }
            blobread.Close();
            Console.ReadKey();
        }

the input.txt is simply this

enter image description here

I am trying to get the streamreader to read the .'s and #'s one by one, I assumed .Read was for this but when i try to use it, it simply doesnt run.

I've tried parsing the .Read, ive tried using .ReadLine but that reads the entire line, I simply want each slot of the 2d array filled with either an . # or A, not a whole string.

0

There are 0 answers