title: extracting data from text file using C#
body: <p>i am trying to extract data from a text file using c#
  the contents of the file are like this-</p>
  
  <pre><code>2002/01/10 00:44:51.53  40.4415 -126.0167  25.37  3.92   Md   56 269  147 0.29 NCSN   21208454 
  </code></pre>
  
  <p>now i want the data from the text file to be stored in variables like this-</p>
  
  <p>date=2002/01/10</p>
  
  <p>time=00:44:51.53</p>
  
  <p>lat=40.4415  and so on..</p>
  
  <p>here is the snippet of code that i have used</p>
  
  <pre><code>     public class data
    {
    public string date, time;
    public double lat, lon,depth,mag;
    }
  
   class Program
   {
  
  static void Main(string[] args)
  {
      string dt;
      List&lt;data&gt; gd = new List&lt;data&gt;();
      using (StreamReader sr = new StreamReader("E:\\op.html"))
      {
          while (sr.Peek() &gt; 0)
          {
              string str;
              string[] arr;
              str = sr.ReadLine();
              arr = str.Split(' ');
              data d = new data();
              d.date = arr[0];
              //d.time = arr[1];
              //d.lat = Convert.ToDouble( arr[2]);
              //d.lon = Convert.ToDouble(arr[3]);
              //d.depth = Convert.ToDouble(arr[4]);
              //d.mag = Convert.ToDouble(arr[5]);
  
  
              Console.WriteLine(d.date);
              //Console.WriteLine(d.time);
              //Console.WriteLine(d.lat);
              //Console.WriteLine(d.lon);
              //Console.WriteLine(d.depth);
              //Console.WriteLine(d.mag);
              Console.ReadKey();
  
          }
  </code></pre>
  
  <p>but i only get the value of d.date,can't get the rest of the values. the lines marked with "//" throws an error "IndexOutOfBound" Error.. how to fix this?</p>