Monday, January 30, 2012

Best Extension Methods: Paging on IEnumerables

Below extension method provides easy way to perform paging on IEnumerables.
public static IEnumerable Page(this IEnumerable source, int page, int pageSize)
    {
        return source.Skip((page - 1) * pageSize).Take(pageSize);
    }

Compiled By: Rajesh Rolen

Share This!


No comments:

Powered By Blogger · Designed By Seo Blogger Templates