Dynamic Array/List

Hi Guys.
I’m trying to figure out the best way of creating a 3 dimensional array (x,y,z) of letters (a,b,c etc).

I would like:

  1. All axis to be able to grow and shrink dynamically.
  2. Easy access to change the content
  3. Move whole columns and rows up and down and sideways.
  4. They would preferably be as light as possible (Saving and loading)

So my question is What is my best tool for this?

Thanks in advance.

Arvid

I would make your own struct or class with a b c in it for public variables than use list()

Thanks for the quick reply. just to make sure I’ve explained myself right here’s a drawing:
1923043--124164--Untitled-1.jpg
I basically want to be able to switch the red index to whatever string I want and do the other things i wrote in the first post.
Is that how you understood my question too?

Thanks guys.
Much appreciated

A

Why are you using strings? Why can’t you just use a List ?

1 Like

hey guys.
Maybe I’m thinking the wrong way about this but how would List work IF:
I want to let’s say add a “q” to index x1 y6 z3 OR read what value x4 y7 z0 holds at the moment in the list?

Ah. I see. Just roll your own then

public class IndexedString
{
    public int X { get; private set; }
    public int Y { get; private set; }
    public int Z { get; private set; }
    public string Value { get; set; }

    public IndexedString(int x, int y, int z, string value)
    {
        this.X = x;
        this.Y = y;
        this.Z = z;
        this.Value = value;
    }
}
var indexedStrings = new List<IndexString>();

Lookups are a bit trickier. Nested Dictionaries are the most straightforward approach.

Dictionary <int3, string>
where the int3 key is a custom struct
Wrapped with custom indexer and methods to shift rows & colums

2 Likes