top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is jagged array in C# ??

+2 votes
416 views
What is jagged array in C# ??
posted Mar 9, 2014 by Atul Mishra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

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."

string[][] arrays = new string[10][];

That's a collection of ten different string arrays, each could be a different length (they could also be the same length, but the point is there is no guarantee that they are).

arrays[0] = new string[5];
arrays[1] = new string[100];
...

This is different from a 2D array where it is rectangular, meaning each row has the same number of columns.

string[,] array = new string[3,5];

Credit: http://stackoverflow.com/questions/2576759/what-is-a-jagged-array

answer Mar 12, 2014 by Salil Agrawal
Similar Questions
0 votes

#region shell_sort

          //element for one step of sort
          int elm = 3;

          for (int i = 0; i != niz_brojeva.Length; i++)
          {
              int j = i + elm;

              if (j >= niz_brojeva.Length)
              { j = Convert.ToInt32(niz_brojeva.Length - 1); }

              while (i != j)
              {

                  if (niz_brojeva[i] > niz_brojeva[j])
                  {
                      int temp;
                      temp = niz_brojeva[i];
                      niz_brojeva[i] = niz_brojeva[j];
                      niz_brojeva[j] = temp;          
                  } j--; }
                 }
     #endregion
...