I'm trying to loop through a reader and put all the values into a
generic list.
public T RStoList<T>(SqlDataReader rdr, int index)
{
List<T> list = new List<T>();
while (rdr.Read())
{
list.Add(rdr.GetValue(index));
}
return list;
}
It's not letting me add the object to the list though. I need to
somehow convert the value from the reader into the right type T.
Tried this without success:
list.Add(Convert.ChangeType(rdr.GetValue(index),typeof(T)));
Ideas?