jagged arrays with multidimensional array

This is a discussion on jagged arrays with multidimensional array within the C# Programming forums, part of the General Programming Boards category; Jagged arrays, namely arrays of arrays is basically similar to a regular dimensional array, which is not hard to understand. ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    65

    jagged arrays with multidimensional array

    Jagged arrays, namely arrays of arrays is basically similar to a regular dimensional array, which is not hard to understand. But here within a jagged array, there is another array, which is kind of a bit vague to me.

    here is a jagged array with a two dimensional array:


    int [][,] jagged = new int [3][,];

    // so there are three rows

    |---------| // row 0;
    |---------|

    |---------| // row 1;
    |---------|

    |---------| // row 2;
    |---------|

    // When we assign jagged [0] a reference to a 4 x 2 array.

    jagged [0] = int new [4,2];

    // Does it mean that we assign four columns to the row 0?

    |---------| |---------| |---------| |---------|
    |---------| |---------| |---------| |---------|

    // and within each row, there are two more rows?

    |--0----1---| |--0----1---| |--0----1---| |--0----1---|
    |------0----| |-------1----| |-----2-----| |------3-----|

    // So when we assign value to jagged [0][1,0] = 10;
    // Does it mean that we access to the second column, which is 1 of the row 0 and
    // assign the value 10 to the second row of 1, which is above the column named 1
    // 0 and 1, and we assign the 10 to 1, not 0?

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Code:
    int [][,] jagged = new int [3][,];|
    Means that you have an array of 2D arrays.

    Code:
    jagged [0] = int new [4,2];
    So you assign on jagged[0] a new 4X2 array.

    jagged[0] =
    * *
    * *
    * *
    * *

    If you do
    Code:
    jagged [1] = int new [3,3];
    jagged[1] =
    * * *
    * * *
    * * *

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    1
    I thing that: here is a jagged array with a two dimensional array:


    int [][,] jagged = new int [3][,];
    _______________
    medical SEO | doctor website | medical practice marketing

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. Replies: 0
    Last Post: 05-29-2009, 05:48 AM
  3. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  4. Multidimensional Array in a Structure
    By Night_Blade in forum C Programming
    Replies: 3
    Last Post: 04-04-2005, 08:14 PM
  5. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 12:01 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21