[C#] 纯文本查看 复制代码
//分页帮助类
public class PageHelper
{
/// <summary>
/// 返回要输出的分页数量
/// </summary>
/// <param name="pageCount">总页数</param>
/// <param name="pageIndex">当前页</param>
/// <returns>实际的页码</returns>
public static List<int> GetIndex(int pageCount, int pageIndex)
{
//开始页
int left = 1;
//结束页
int right = pageCount;
//在显示的页码数组
List<int> ar = new List<int>();
if (pageCount >= 10)
{
if (pageIndex > 6 && pageIndex < pageCount - 4)
{
left = pageIndex - 5;
right = pageIndex + 4;
}
else
{
if (pageIndex <= 6)
{
left = 1;
right = 10;
}
else
{
right = pageCount;
left = pageCount - 8;
}
}
}
while (left <= right)
{
ar.Add(left);
left++;
}
return ar;
}
}