How to filter a List<Customer> filled with Objects
I have a class Person and a list of type List<Person>
class person
{
int id;
string FirstName;
string LastName;
}
I have ten Person objects filled it the List.
My List is bound to Jqgrid. On Paging i want to filter the L开发者_如何学运维ist and bind the grid with the data for that Page.
So if anyone can tell me how to do paging on a List<Person>
It's not clear whether you are trying to filter the List or page the results. The typical way to page results is using a combination of Skip()
and Take()
:
public static IEnumerable<T> Page(this List<T> list, int pageSize, int pageNum)
{
return list.Skip(pageSize * pageNum).Take(pageSize);
}
精彩评论