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;
}
The following code does not compile. MistakeArrayList is not IEnumerable
ArrayList lstStudents = GetStudentAsArrayList();
var res = from r in lstStudents select r;
This compiles:
ArrayList lstStudents = GetStudentAsArrayList();
var res = from Student r in lstStudents select r;
Can anyone explain what the difference is between the two fragments? Why does the second work?
source
share