import java.*;
public class Test
{
public static void main(String[] args)
{
int[][] arg={{0,1,2,3},{4,5,6}};
for(int i=0;i<arg.length;i++)
{
for(int j=0;j<arg[i].length;j++)
{
System.out.print("Java二维数组"+arg[i][j]);
}
System.out.println("");
}
}
}
using System;
public class Test
{
public static void Main(String[] args)
{
int[,] arg = { { 1, 2, 3, 4 }, { 5, 6, 7,8} };
for (int i = 0; i < arg.GetLength(0); i++)//取得第一维长度
{
for(int j=0;j<arg.GetLength(1);j++)//取得第二维长度
{
Console.Write("NET二维数组" + arg[i, j]);
}
Console.WriteLine();
}
Console.Read();
}
}
using System;
public class Test
{
public static void Main(String[] args)
{
int[,] arg = { { 1, 2, 3, 4 }, { 5, 6, 7,8 } };
foreach (int intArg in arg)
{
Console.WriteLine("用foreach遍历NET二维数组"+intArg );
}
Console.Read();
}
}
java数组的第二维长度可以不同,而C#第二维长度要相同,给人感觉是Java更贴近现实生活。