开发者

How to filter a List<Customer> filled with Objects

开发者 https://www.devze.com 2023-02-28 22:42 出处:网络
I have a class Person and a list of type List<Person> class person { int id; string FirstName; string LastName;

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);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号