Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Jagged Arrays Definition

Jagged Arrays Definition

Scheduled Pinned Locked Moved C#
questiondata-structures
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sokka93
    wrote on last edited by
    #1

    Hello everyone. As far as I know Jagged array is also called "array of array" does that mean that I can use a definition like int[][][] Jagged Array = new int[3][3][]? And does it mean "array of array of array"? I mean if I use something like that does it contain 9 arrays in it? if I'm wrong how can I define something like that? Thanks in advance!

    R L B 3 Replies Last reply
    0
    • S Sokka93

      Hello everyone. As far as I know Jagged array is also called "array of array" does that mean that I can use a definition like int[][][] Jagged Array = new int[3][3][]? And does it mean "array of array of array"? I mean if I use something like that does it contain 9 arrays in it? if I'm wrong how can I define something like that? Thanks in advance!

      R Offline
      R Offline
      Rick Shaub
      wrote on last edited by
      #2

      All of your answers can be found on MSDN: http://msdn.microsoft.com/en-us/library/2s05feca.aspx[^]

      1 Reply Last reply
      0
      • S Sokka93

        Hello everyone. As far as I know Jagged array is also called "array of array" does that mean that I can use a definition like int[][][] Jagged Array = new int[3][3][]? And does it mean "array of array of array"? I mean if I use something like that does it contain 9 arrays in it? if I'm wrong how can I define something like that? Thanks in advance!

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Almost, yes it would be "an array of (array of (array of ints))" (with parentheses for extra clearness) However, you can only create 1 array at the time, so you can make a new int[3][][], but then you'd have to loop over it and fill every entry with a new int[3][] You would then have 9 places in which you could put an "array of int" (but they are all null) so only 1 + 3 arrays in total (the outer array and the three middle arrays). (until you also create the arrays of ints) It's not all that useful to do this though (when all sub-arrays have the same length), you might as well make a new int[9][] and index it with [3*i+j] instead of [i][j], which takes much less code (you don't have to fill the outer array with arrays). You could extend this to three dimensions if all arrays of int will be the same length.

        S 1 Reply Last reply
        0
        • L Lost User

          Almost, yes it would be "an array of (array of (array of ints))" (with parentheses for extra clearness) However, you can only create 1 array at the time, so you can make a new int[3][][], but then you'd have to loop over it and fill every entry with a new int[3][] You would then have 9 places in which you could put an "array of int" (but they are all null) so only 1 + 3 arrays in total (the outer array and the three middle arrays). (until you also create the arrays of ints) It's not all that useful to do this though (when all sub-arrays have the same length), you might as well make a new int[9][] and index it with [3*i+j] instead of [i][j], which takes much less code (you don't have to fill the outer array with arrays). You could extend this to three dimensions if all arrays of int will be the same length.

          S Offline
          S Offline
          Sokka93
          wrote on last edited by
          #4

          Thank you so much!

          1 Reply Last reply
          0
          • S Sokka93

            Hello everyone. As far as I know Jagged array is also called "array of array" does that mean that I can use a definition like int[][][] Jagged Array = new int[3][3][]? And does it mean "array of array of array"? I mean if I use something like that does it contain 9 arrays in it? if I'm wrong how can I define something like that? Thanks in advance!

            B Offline
            B Offline
            BillWoodruff
            wrote on last edited by
            #5

            Hi Sokka93, For an excellent discussion of "jagged arrays" compared to "multidimensional" arrays, see : [^] For performance comparisons of jagged and multidimensional arrays see : [^] best, Bill

            "Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844

            S 1 Reply Last reply
            0
            • B BillWoodruff

              Hi Sokka93, For an excellent discussion of "jagged arrays" compared to "multidimensional" arrays, see : [^] For performance comparisons of jagged and multidimensional arrays see : [^] best, Bill

              "Many : not conversant with mathematical studies, imagine that because it [the Analytical Engine] is to give results in numerical notation, its processes must consequently be arithmetical, numerical, rather than algebraical and analytical. This is an error. The engine can arrange and combine numerical quantities as if they were letters or any other general symbols; and it fact it might bring out its results in algebraical notation, were provisions made accordingly." Ada, Countess Lovelace, 1844

              S Offline
              S Offline
              Sokka93
              wrote on last edited by
              #6

              Thanks!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups