静夜思之将一组数据按另一组数据中的值分组
作者:互联网
本来很简单的东西,楞是想了许久。
比如将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]; } }
标签:files,name,另一组,int,maxindex,limtindex,思之将,limts,静夜 来源: https://www.cnblogs.com/shishiru/p/16201100.html