class Program { static void Main(string[] args) { List<string> ids = new List<string> { "1", "2", "3", "4", "5", "6", "7", "8" }; int count = Math.Min(ids.Count, 2);//每批获取的多少条 int len = ids.Count;//数据总条数 int size = len % count;//需要分几次获取 if (size == 0) { size = len / count; } else { size = (len / count) + 1; } Console.WriteLine($"每批取两条需要{size}批"); for (int i = 0; i < size; i++) { int fromIndex = i * count;//从哪儿开始 //int toIndex = Math.Min(fromIndex + count, len);//到哪儿结束 List<string> needData = ids.Skip(fromIndex).Take(count).ToList(); Console.WriteLine($"第{i+1}批:" + string.Join("','", needData)); } Console.ReadKey(); } }