What is the best method to resize 3 dimension array in C#?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Damien582
    New Member
    • Aug 2008
    • 9

    What is the best method to resize 3 dimension array in C#?

    Hi guys, new here. I've used this site for a while researching answers, but this is my first post. I've searched everywhere and I haven't found an answer that works. First, what I am doing: Cubed array (3 dimesions, not jagged) of a custom structure for a game I am making to hold tile information. I can resize a 2 dimensional layer just fine, but upon resizing a 3 dimensional array (via creating new array and using Array.Copy) I could not figure out how to copy the data from the old array to the new one. I prefer not to use List or ArrayList as I am goifn to save the array in a file as a mapfile. Please anyone, some insite, links or anything would be helpful!!!
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    You could copy the values manually using some nested for loops.
    3D arrays are so Foranesque. Why not use a class to represent that structure?

    Comment

    • Damien582
      New Member
      • Aug 2008
      • 9

      #3
      Originally posted by r035198x
      You could copy the values manually using some nested for loops.
      3D arrays are so Foranesque. Why not use a class to represent that structure?
      I am using a Class (Editor) to encapsulate the data structure and sizing functions. The array is of a custom structure Tile{int Layer,int x,int y, int Width, int Height,int TextureId}
      These are to represent tiles in a multi-layer 2d tile based game. Rather than serialize an object I would prefer to keep the structure as simple as possible to reduce file size when saved.

      Comment

      Working...