现在的位置: 首页 > 综合 > 正文

另一个分页函数

2012年10月07日 ⁄ 综合 ⁄ 共 996字 ⁄ 字号 评论关闭
        /// <summary>
        /// Gets the page.
        /// </summary>
        /// <param name="pageIndex">Index of the page.第几页,从1开始算</param>
        /// <param name="pageSize">Size of the page.每页的大小</param>
        /// <param name="totalSize">The total size.记录总数</param>
        /// <returns>返回从0开始的记录</returns>
        static int[] GetPage(int pageIndex, int pageSize, int totalSize)
        {
            pageIndex--;
            List<int> ps = new List<int>();
            int p = 0;
            while (p < totalSize)
            {
                p++;
                if (p > pageSize * (pageIndex) && p <= pageSize * (pageIndex + 1))
                    ps.Add(p-1);//当符合此页时发生
            }
            return ps.ToArray();
        }

抱歉!评论已关闭.