在一个遍历循环中,如何再循环输出一个数组?

2024-12-31 02:05:05
推荐回答(3个)
回答1:

长度都是3个。一个循环里就可以搞定。
int[] arr1 = new int[] { 1, 2, 3 };
int[] arr2 = new int[] { 4, 5, 6 };
int i = 0;
for(i=0;i {
Response.Write(arr1[i]);
Response.Write(arr2[i]);
}

回答2:

int[] arr1 = new int[] { 1, 2, 3 };
int[] arr2 = new int[] { 4, 5, 6 };
int i = 0;
for(i=0;i {
Response.Write(arr1[i]);
Response.Write(arr2[i]);
}

回答3:

foreach (int i in arr1)
{
Response.Write(arr1[i]+arr2[i]);
}