title: Filling array from text file and then writing them in console C#
body: <p>Here is my code.. 
  exercise asked to write those integers into file, then open the file and fill the two dimensional array with those integers from file and then print it on the console.</p>
  
  <p>Here is the code I've written and after running it in Visual Studio 2010, it gave me strange errors... can you help me with that to examine whats the problem in the code?</p>
  
  <p>Here is the code I wrote:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.IO;
  
  namespace ConsoleApplication1
  {
      class Program
      {
          static void Main(string[] args)
          {
              FileStream fs = new FileStream("C:\\Users\\Guest\\Desktop\\hi.txt", FileMode.Create);
              StreamWriter sw = new StreamWriter(fs);
              string filepath = "C:\\Users\\Guest\\Desktop\\hi.txt";
  
              sw.WriteLine("6,73,6,71");
              sw.WriteLine("32,1,0,12");
              sw.WriteLine("3,11,1,134");
              sw.WriteLine("43,15,43,6");
              sw.WriteLine("55,0,4,12");
              sw.Close();
  
              StreamReader sr = new StreamReader(fs);
              int [,] data = new int[4,5];
              using (StreamReader reader = File.OpenText(filepath))
              {
                  for (int r = 0; r &lt; data.GetLength(0); r++)
                  {
                      for (int c = 0; c &lt; data.GetLength(1); c++)
                      {
                        /* 
                          if (reader.EndOfStream)
                          {
                              return ricxvebi;
                          } 
                         */
                               data[r, c] = int.Parse(reader.ReadLine());
                      }
                  }
              }
  
              var rowCount = data.GetLength(0);
              var colCount = data.GetLength(1);
              for (int row = 0; row &lt; rowCount; row++)
              {
                  for (int col = 0; col &lt; colCount; col++)
                      Console.Write(String.Format("{0}\t", data[row, col]));
                  Console.WriteLine();
              } 
  
  
          }
      }
  }
  </code></pre>