// 一维数组
int[] arr = { 1, 2, 3, 4, 5 };
foreach (int i in arr)
{
Console.WriteLine(i.ToString() + "\r");
}
// 二维数组
int[,] arr2 = { { 1, 2 }, { 3, 4 } };
foreach (int i in arr2)
{
Console.WriteLine(i.ToString());
}
// 交错数组
int[][] CrossArray = new int[3][] { new int[] { 1, 2 }, new int[] { 3, 4, 5},new int[] { 6,7,8,9} };
foreach (int[] arr in CrossArray) {
foreach (int i in arr) {
Console.WriteLine(i.ToString());
}
时间: 2024-10-13 07:00:00