in Technology by

What is a Jagged Array in C#?

1 Answer

0 votes
by
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."
 
A special type of array is introduced in C#. A Jagged Array is an array of an array in which the length of each array index can differ.
 
Example
  1. int[][] jagArray = new int[5][];    
In the above declaration, the rows are fixed in size. But columns are not specified as they can vary.
 
Declaring and initializing a jagged array.
  1. int[][] jaggedArray = new int[5][];         
  2. jaggedArray[0] = new int[3];    
  3. jaggedArray[1] = new int[5];    
  4. jaggedArray[2] = new int[2];    
  5. jaggedArray[3] = new int[8];    
  6. jaggedArray[4] = new int[10];    
  7. jaggedArray[0] = new int[] { 3, 5, 7, };    
  8. jaggedArray[1] = new int[] { 1, 0, 2, 4, 6 };    
  9. jaggedArray[2] = new int[] { 1, 6 };    
  10. jaggedArray[3] = new int[] { 1, 0, 2, 4, 6, 45, 67, 78 };    
  11. jaggedArray[4] = new int[] { 1, 0, 2, 4, 6, 34, 54, 67, 87, 78 };     

Related questions

0 votes
    Thinking like a simple array: Console.WriteLine("Number: "); int x = Convert.ToInt32(Console.ReadLine()) ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    Thinking like a simple array: Console.WriteLine("Number: "); int x = Convert.ToInt32(Console.ReadLine()) ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    Thinking like a simple array: Console.WriteLine("Number: "); int x = Convert.ToInt32(Console.ReadLine()) ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    Thinking like a simple array: Console.WriteLine("Number: "); int x = Convert.ToInt32(Console.ReadLine()) ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Which of the following returns an array of ones with the same shape and type as a given array? (a) all_like (b) ones_like (c) one_alike (d) all of the mentioned...
asked Oct 9, 2021 in Technology by JackTerrance
0 votes
    The ________ function returns its argument with a modified shape, whereas the ________ method modifies the array itself. (a) ... (c) reshape2, resize (d) all of the mentioned...
asked Oct 7, 2021 in Technology by JackTerrance
0 votes
    ndarray is also known as the alias array. (a) True (b) False...
asked Oct 7, 2021 in Technology by JackTerrance
0 votes
    Which of the following method creates a new array object that looks at the same data? (a) view (b) copy (c) paste (d) all of the mentioned...
asked Oct 7, 2021 in Technology by JackTerrance
0 votes
    Point out the wrong statement. (a) Each universal function takes array inputs and produces array outputs (b) Broadcasting ... input arguments are ndarrays (d) All of the mentioned...
asked Oct 7, 2021 in Technology by JackTerrance
0 votes
    How to convert ArrayList to Array and Array to ArrayList in JAVA?...
asked May 27, 2021 in Technology by JackTerrance
0 votes
    What is the difference between the length of an Array and size of ArrayList in Java?...
asked May 27, 2021 in Technology by JackTerrance
0 votes
    What are the main differences between array and collection?...
asked May 26, 2021 in Technology by JackTerrance
0 votes
    In MongoDB, _________ is the operator limits the contents of an array field from the query. (1)$Match (2)$elemMatch (3)$slice...
asked May 23, 2021 in Technology by JackTerrance
0 votes
0 votes
    Create a two 2-D array. Plot it using matplotlib...
asked Apr 24, 2021 in Technology by JackTerrance
...