How do I iterate through an IList collection and return only n number of records? I am trying to implement paging using an IList object.
+1
A:
(From o As Object In myList).Take(n)
Hanselman has a good Paginated List class in his ASP .NET MVC tutorial here. You should check it out.
Brandon Montgomery
2009-04-20 20:39:18
+1
A:
foreach (int i in myList.Take(4))
{
// do some stuff
}
It's worth noting that for pagination, you'll also want some sort of offset. To do so, you could do the following as well:
foreach (int i in myList.Skip(40).Take(20)) { }
In C#.
Tony k
2009-04-20 20:41:24