title: How to read from text file to array?
body: <p>what's up everybody, </p>
  
  <p>I have this problem in my code and I couldn't figure out how to read from text file and put it in 2-dimension array of double type array [1024,8] in c# .</p>
  
  <pre><code>0   148.9    19.4    20.2   112.6    41.9   205.7    46.7    87.2 
  1    41.4    97.1    86.4   102.5    99.1   183.1    47.7    84.0
  2   154.8   303.1   252.2   110.7    74.5    59.7   193.7   361.6 
  .
  .
  1023    40.8   136.8   222.1    39.5   104.9    35.3    76.0   111.4 
  </code></pre>
  
  <hr>
  
  <p>I tried to read this file line by line, but this way didn't help me </p>
  
  <pre><code>static void Main(string[] args)
  {
      int counter = 0;
      string line;
      double[] task = new double[8];
      // Read the file and display it line by line.
      System.IO.StreamReader file =
         new System.IO.StreamReader("c:\\test.txt");
      //int count = 0;
      while ((line = file.ReadLine()) != null &amp;&amp; counter &lt;= 1023)
      {
          //count++;
          //Console.WriteLine(count);
  
          string[] numbers = new string[8];
          int numCount = 0;
          for (int i = 0; i &lt; line.Length; i++)
          {
              if (line[i] != ' ')
              {
                  numbers[numCount] = "";
                  while (line[i] != ' ')
                  {
                      numbers[numCount] += line[i];
                      i++;
                  }
                  numCount++;
              }
          }
          for (int i = 0; i &lt; 8; i++)
          {
              task[i] = Convert.ToDouble(numbers[i]);
          }
          counter++;
          Console.WriteLine("The array contain:");
          for (int i = 0; i &lt; 8; i++)
              Console.WriteLine(task[i]);
      }
      file.Close();
      // Suspend the screen.
      Console.ReadLine();
  }
  </code></pre>