本来很简单的东西,楞是想了许久。
比如将12个文件按照limts的值分为三组,
files.AddRange(new string[12] { "s1", "s2", "s3", "s4", "s5", "s6", "s7", "s8", "s9", "s10", "s11", "s12" }); limts.AddRange(new int[3] { 4, 4, 4 });
以字符串name和names分组储存,
name = ""; int limtindex = 0; int maxindex = limts[limtindex] - 1; for (int i = 0; i < files.Count; i++) { name += files[i] + "&&"; if (i == maxindex && i != files.Count - 1) { names.Add(name); limtindex++; name = ""; maxindex += limts[limtindex]; } }