dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Use LINQ Methods to Implement Paging in C#

With the Skip and Take methods in LINQ, paging has become much easier. Learn how to use them to provide paging for your items.


advertisement

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


With the Skip and Take methods in LINQ, paging has become a lot easier.

All we need to do is have a simple logic such as is outlined below. This will provide the paged items.

var pagedItems = theListWithLotsOfItems.Skip ((pageNumber - 1) * pageSize).Take(pageSize);

pageNumber(1) and pageSize(10) will provide first 10 items, and pageNumber(2) and pageSize(10) will provide second page data - another 10 items and so on.

 

Visit the DevX Tip Bank

 





   
Srinath M. S. says: "I would love to leave a footprint in this flat world."
Thanks for your registration, follow us on our social networks to keep up-to-date