Multidimensional data structure?

Posted by Austin Truong on Stack Overflow See other posts from Stack Overflow or by Austin Truong
Published on 2012-10-23T16:34:25Z Indexed on 2012/10/23 17:00 UTC
Read the original article Hit count: 225

I need a multidimensional data structure with a row and a column.

  • Must be able to insert elements any location in the data structure. Example: {A , B} I want to insert C in between A and B. {A, C, B}.
  • Dynamic: I do not know the size of the data structure.
  • Another example: I know the [row][col] of where I want to insert the element. EX. insert("A", 1, 5), where A is the element to be inserted, 1 is the row, 5 is the column.

EDIT
I want to be able to insert like this.

    static void Main(string[] args)
    {
        Program p = new Program();
        List<string> list = new List<string>();
        list.Insert(1, "HELLO");
        list.Insert(5, "RAWR");
        for (int i = 0; i < list.Count; i++)
        {
            Console.WriteLine(list[i]);
        }
        Console.ReadKey();
    }

And of course this crashes with an out of bounds error.

So in a sense I will have a user who will choose which ROW and COL to insert the element to.

© Stack Overflow or respective owner

Related posts about c#

Related posts about data-structures