title: randomly select a line in a textfile c# streamreader
body: <p>Hi I am reading from a text file and would like each line to be put into a seperate variable. From what I remember from my programming classes arrays cannot be dynamic. So if I set 15 arrays, and the text file has 1000 lines what can I do and how do I implement it. </p>
  
  <p>The thing is only one line will be needed but I want the line to be randomly selected. the linetext is the whole text file with \r\n appended to the end of every request. </p>
  
  <p>Maybe randomly select the \r\n then count 4 and add the string after it till the next \r\n. The problem with this idea is the strings getting called will also contain \ so any ideas?</p>
  
  <pre><code>if (crawler == true)
     {
              TextReader tr = new StreamReader("textfile.txt");
              while (tr.Peek() != -1)
              {
                  linktext = linktext + tr.ReadLine() + "\r\n";
              }
  
              //link = linktext;
  
              hi.Text = linktext.ToString();
  
              timer1.Interval = 7000; //1000ms = 1sec 7 seconds per cycle
              timer1.Tick += new EventHandler(randomLink); //every cycle randomURL is called.
              timer1.Start(); // start timer.
          }
  </code></pre>