可能重复:
How can I easily convert DataReader to List<T>?如何将DataReader中的值放入列表<T>?
我希望把它从DataReader对象来在通用列表中的数据。我做了这样的,但它不工作...
我在foreach行得到抛出异常错误!
SqlDataReader pointreader = cmd2.ExecuteReader();
var pointt = new List<int>();
while (pointreader.Read())
{
foreach (int item in pointreader)
{
pointt.Add(item);
if (pointt.Contains(point))
{
matchpoint = item;
}
}
}
可能从这里[link](http://stackoverflow.com/questions/1464883/how-can-i-easily-convert-datareader-to-listt) – Dotnet 2011-05-18 09:26:13
请将您的变量名称重命名为英文 - 写 – abatishchev 2011-05-18 09:40:32
我已编辑abatishchev – PsyGnosis 2011-05-18 10:06:33