我正在循环遍历一个字符串数组,例如 (1/12/1992 苹果 卡车 12/10/10 橘子 自行车)。该数组的长度总是可以被3整除的。我需要循环遍历该数组,获取前3个项目(我将把它们插入到数据库中),然后获取接下来的3个项目,依此类推,直到所有项目都被遍历完毕。
//iterate the array
for (int i = 0; i < theData.Length; i++)
{
//grab 3 items at a time and do db insert, continue until all items are gone. 'theData' will always be divisible by 3.
}
theData[i]
应该是你的日期,theData[i+1]
应该是你的水果类型,而theData[i+2]
应该是你的汽车。有什么问题吗? - froadieforeach
循环呢?不知道为什么没有人提出这个建议。 - undefined