【发布时间】:2016-04-07 05:35:37
【问题描述】:
这是我的简单示例:
IList<string> files = new string[] { "file1", "file2", "file3" };
IList<string> words = new string[] { "first", "second", "third", "fourth", "fifth", "sixth" };
foreach (var file in files) {
int i = 1;
foreach (var word in words) {
MessageBox.Show(i.ToString());
i++;
}
}
每次迭代后,我想在 MessageBox 中看到1、2、3、4、5、6、7、8、9、 10, 11, 12, 13, 14, 15, 16, 17, 18 但它给了我 3 次 14, @3 987654342@、4、5、6
这可能是我想要的吗?
【问题讨论】: