Why LINQ will work this way?
- by Benny
public static ArrayList GetStudentAsArrayList()
{
ArrayList students = new ArrayList
{
new Student() { RollNumber = 1,Name ="Alex " , Section = 1 ,HostelNumber=1 },
new Student() { RollNumber = 2,Name ="Jonty " , Section = 2 ,HostelNumber=2 },
};
return students;
}
this doesn't compile: ArrayList is not IEnumerable
ArrayList lstStudents = GetStudentAsArrayList();
var res = from r in lstStudents select r;
but this will compile:
ArrayList lstStudents = GetStudentAsArrayList();
var res = from Student r in lstStudents select r;
Can anybody explain? what's the magic here?