【发布时间】:2014-05-19 17:48:19
【问题描述】:
我可以简化我的代码吗?
我有很长的清单。我使用一些 API,每个方法调用最多接受 25 条记录。
我写了简单的分页
List<long> items = new List<long>(); // this will contain 100+ records
int itemsCnt = items.Count();
int pagesCnt = (itemsCnt + (itemsCnt % 25)) / 25; // calculating total pages
int page = 0;
while (page < pagesCnt)
{
List<long> itemsSinglePageList = items.GetRange(page, 25);
ProcessPageOfRecords(itemsSinglePageList);
page++;
}
我想知道我是否可以简化一下。
【问题讨论】:
-
这个问题似乎跑题了,因为它属于codereview.stackexchange.com
-
我觉得 stackoverflow 走错了路。我想知道“questions_about_for_loops_in_cpp.stackexchange.com”或“questions_about_tables_in_html.stackexchange.com”之类的网站何时开始出现。
标签: c# pagination