如何将var类型转换/转换为List类型?C# - var到List <T>转换
这段代码是给我的错误:
List<Student> studentCollection = Student.Get();
var selected = from s in studentCollection
select s;
List<Student> selectedCollection = (List<Student>)selected;
foreach (Student s in selectedCollection)
{
s.Show();
}
'var'不是一个类型,它只是您分配给该变量的任何表达式类型的占位符。在这种情况下,查询表达式的计算结果为“IEnumerable”。 –
Joren
2009-10-11 17:58:41