C# List 分页代码
List<int> testList = new List<int>();
for (int i = 1; i <= 23; i++)
{
testList.Add(i);
}
// 每页大小
int pageSize = 5;
// 总页数
int pageCount = Convert.ToInt32(Math.Ceiling(1.0 * testList.Count / pageSize));
// 页码
int pageIndex = 0;
for (int i = 0; i < pageCount; i++)
{
var tempList = testList.Skip(pageSize * pageIndex).Take(pageSize);
Console.WriteLine(tempList);
pageIndex++;
}
posted on 2022-12-06 10:32 Tencent/Tim 阅读(105) 评论(0) 编辑 收藏 举报