using System;
class Program
{
static void Main()
{
int[][] arr = new int[2][];
arr[0] = new int[3] { 1, 3, 5 };
arr[1] = new int[4] { 2, 4, 6, 8 };
for (int i = 0; i < arr.Length; i++)
{
Console.Write("Element({0}): ", i);
for (int j = 0; j < arr[i].Length; j++)
{
Console.Write("{0}{1}", arr[i][j], j == (arr[i].Length - 1) ? "" : " ");
}
Console.WriteLine();
}
Console.ReadKey();
}
}
|
Class Program
Private Shared Sub Main()
Dim arr As Integer()() = New Integer(1)() {}
arr(0) = New Integer(2) {1, 3, 5}
arr(1) = New Integer(3) {2, 4, 6, 8}
For i As Integer = 0 To arr.Length - 1
Console.Write("Element({0}): ", i)
For j As Integer = 0 To arr(i).Length - 1
Console.Write("{0}{1}", arr(i)(j), If(j = (arr(i).Length - 1), "", ""))
Next
Console.WriteLine()
Next
Console.ReadKey()
End Sub
End Class
|