Patel Chirag
What is Jagged Array?(related to C#)
By Patel Chirag in ASP.NET on Mar 12 2007
  • Mar, 2007 13

    Jagged Arrays or most important array althought it have some limitation like at defination itself you need to specify everything but helps lot. These arrays does not work as normal array. A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array of arrays." The following examples show how to declare, initialize, and access jagged arrays. int[][] jaggedArray = new int[3][]; jaggedArray[0] = new int[5]; jaggedArray[1] = new int[4]; jaggedArray[2] = new int[2]; jaggedArray[0] = new int[] { 1, 3, 5, 7, 9 }; jaggedArray[1] = new int[] { 0, 2, 4, 6 }; jaggedArray[2] = new int[] { 11, 22 }; An example for same is as follows, class ArrayTest { static void Main() { // Declare the array of two elements: int[][] arr = new int[2][]; // Initialize the elements: arr[0] = new int[5] { 1, 3, 5, 7, 9 }; arr[1] = new int[4] { 2, 4, 6, 8 }; // Display the array elements: for (int i = 0; i < arr.Length; i++) { System.Console.Write("Element({0}): ", i); for (int j = 0; j < arr[i].Length; j++) { System.Console.Write("{0}{1}", arr[i][j], j == (arr[i].Length - 1) ? "" : " "); } System.Console.WriteLine(); } } } link: http://msdn2.microsoft.com/en-us/library/2s05feca.aspx

    • 0
  • Mrinal Jaiswal
    Mar, 2007 12

    A jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array of arrays."

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS