• 分页类


    /// <summary>
        /// 分页列表类
        /// </summary>
        public class PagedList<T>
        {
            /// <summary>
            /// 每页页面大小
            /// </summary>
            public int PageSize { get; private set; }
    
            /// <summary>
            /// 页面总数
            /// </summary>
            public int TotalCount { get; private set; }
    
            /// <summary>
            /// 首页页面Index
            /// </summary>
            public IEnumerable<T> Items { get; private set; }
    
            /// <summary>
            /// .ctor
            /// </summary>
            /// <param name="items">总列表</param>
            /// <param name="pageSize">每页大小</param>
            public PagedList(IEnumerable<T> items, int pageSize)
            {
                PageSize = pageSize;
                TotalCount = items.Count();
                Items = items;
            }
    
            /// <summary>
            /// 总页面数
            /// </summary>
            public int PageCount
            {
                get { return TotalCount % PageSize == 0 ? TotalCount / PageSize : TotalCount / PageSize + 1; }
            }
    
            /// <summary>
            /// 根据页面索引计算当前页在列表中的区间上限
            /// </summary>
            /// <param name="pageIndex"></param>
            /// <returns></returns>
            public int GetStartIndex(int pageIndex)
            {
                return (pageIndex - 1) * PageSize + 1;
            }
    
            /// <summary>
            /// 根据页面索引计算当前页在列表中的区间下限
            /// </summary>
            /// <param name="pageIndex"></param>
            /// <returns></returns>
            public int GetEndIndex(int pageIndex)
            {
                return (pageIndex * PageSize);
            }
    
            /// <summary>
            /// 根据页面索引获得列表中对应的数据
            /// </summary>
            /// <param name="pageIdx"></param>
            /// <returns></returns>
            public IEnumerable<T> SubItems(int pageIdx)
            {
                return this.Items.Skip(GetStartIndex(pageIdx)-1).Take(PageSize);
            }
        }
  • 相关阅读:
    等差子序列(sequence)
    威士忌(whiskey)
    图论:2-SAT模板
    poj2723-Get Luffy Out
    acdream1412:2-3 trees 组合数dp
    hdu3849-By Recognizing These Guys, We Find Social Networks Useful:双连通分量
    ZOJ2317-Nice Patterns Strike Back:矩阵快速幂,高精度
    ZOJ3519-Beautiful People:最长上升子序列的变形
    hdu2460-Network:边的双连通分量
    hdu4405:概率dp
  • 原文地址:https://www.cnblogs.com/zhshlimi/p/8058917.html
Copyright © 2020-2023  润新知