title: How to put values from DataReader into List<T>?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1464883/how-can-i-easily-convert-datareader-to-listt">How can I easily convert DataReader to List&lt;T&gt;?</a>  </p>
  </blockquote>
  
  
  
  <p>I want to put the data which is coming from datareader object in a generic list. I have done like this but it doesn't work...</p>
  
  <p>I am getting cast exception error in foreach row!</p>
  
  <pre><code> SqlDataReader pointreader = cmd2.ExecuteReader();
   var pointt = new List&lt;int&gt;();
   while (pointreader.Read())
   {
       foreach (int item in pointreader)
       {
          pointt.Add(item);
           if (pointt.Contains(point))
           {
               matchpoint = item;
           }
       }
   }
  </code></pre>