c#数组读取存储foreach

c#数组读取存储foreach

[cpp]

using System;
class Test
{
public static void Main()
{
int[] a = { 1, 2, 3, 4, 5, 6 };//一维数组
int[,] b = { { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 9 } };//二维数组
int[][] c = { new int[] { 1, 2, 3, 4 }, new int[] { 5, 6, 7, 8 } };//交错数组
Console.WriteLine(a[2]); //访问方式:
Console.WriteLine(b[2,1]);
Console.WriteLine(c[1][3]);
foreach (int i in b) //
{
Console.Write(“{0,3:d}”, i);
}
}
}

[/cpp]