title: C# stream reader read line to stor in data
body: <p>I have sample.txt here:</p>
  
  <pre><code>ABCDEABCDEABCDEABCDE
  1000 ABCDEABCDEABCDEABCDE
  1001 BCDEABCDEABCDEABCDEA
  1002 CDEABCDEABCDEABCDEAB
  1003 DEABCDEABCDEABCDEABC
  1004 EABCDEABCDEABCDEABCD
  1005 AABBCCDDEEABCDEABCDE
  1006 ABBCCDDEEAABCDEABCDE
  1007 ACBEDADCEBBCDEAABABA
  1008 AAAAAAAAAAAAAAAAAAAA
  1009 BBBBBBBBBBBBBBBBBBBB
  1010 EEEEEEEEEEEEEEEEEEEE
  1011 CCCCCCCCCCCCCCCCCCCC
  1012 DDDDDDDDDDDDDDDDDDDD
  0000 
  </code></pre>
  
  <p>first line is the standard answer, the following are the student ID (4 digits) and student answers(20 digits).
  and the requirement is unless student ID =0000, <strong>else read the line to array.array[0]=student1 id,array[1]=student 1 answeer. or studentID[0]=student 1 ID, answer[0]=student 1 answer.</strong>
  I am not familiar with while condition with increasing i.</p>
  
  <pre><code>namespace ConsoleApp2
  {
      class Program
      {
          static void Main(string[] args)
          {
              int id;
              string line;
              string[] token;
  
  
              var lineCount = File.ReadLines("C:\\testresult\\exam.txt").Count();
              Console.WriteLine(lineCount);
              string[] record = new string[lineCount];
  
              try
              {
                  StreamReader sr = new StreamReader("C:\\testresult\\exam.txt");
                  line = sr.ReadLine();
  
                  line = sr.ReadLine();
                  token = line.Split();
                  id = Convert.ToInt32(token[0]);
                  while (id != 0)
                  {
                      {
                          Console.WriteLine(token[1]);
                          line = sr.ReadLine();
                          token = line.Split();
                          id = Convert.ToInt32(token[0]);
                          for (int i = 0; i &lt; lineCount; i = i + 2)
                          {
                             record[i]=Convert.ToString(id);
                              record[i + 1] = token[1];
                              Console.WriteLine(record[i], record[i + 1]);
  
                          }
                      }
                  }
                  sr.Close();
                  Console.ReadLine();
  
              }
              catch { }
          }
      }
  }
  </code></pre>
  
  <p>can anyone advise how to read lines one by one and store the id and token[0] into each element in the array every time?</p>