C#、List、分页

			int pageIndex = 0; //页码 0也就是第一条 
            int pageSize = 2; //每页条数               
            string[] names = { "刘一", "陈二", "张三", "李四", "王五", "赵六", "孙七", "周八", "吴九" };//源数据  

            Response.Write("
原数据:"
+ string.Join(" ,", names)+ "
"
); while (pageIndex * pageSize < names.Length) { //分页 var query = names.Skip(pageIndex * pageSize).Take(pageSize); foreach (var q in query)//输出每页内容 { Response.Write("
第"
+ (pageIndex + 1) + "页数据:" + q); } pageIndex++; Response.Write("
"
); }

你可能感兴趣的:(C#,Linq,List,分页,c#)