Arrays in Array..
/// <summary>
/// C# Jagged Array Example
/// </summary>
static void Main()
{
int[][] arr = new int[4][];// Declare the array
arr[0] = new int[] { 11, 21, 56, 78 };// Initialize the array
arr[1] = new int[] { 42, 61, 37, 41, 59, 63 };
arr[2] = new int[] { 11 };
arr[3] = new int[] { 12 };
// Traverse array elements
for (int i = 0; i < arr.Length; i++)
{
for (int j = 0; j < arr[i].Length; j++)
{
System.Console.Write(arr[i][j] + " ");
}
System.Console.WriteLine();
}
}
No comments:
Post a Comment