dynamic array

  • Thread starter Thread starter majiofpersia
  • Start date Start date
M

majiofpersia

Hi all,
I am wondering whether any of you knows how to initialize a dynamically
sized multi-dimensional array? I can't use arrayLists, hashtables, or
anything that is key value pair set-up... I need multi-dimensional array in
C#...it is asking me to initialize it with size when I write :

string[,,] myarray = new string[,,];

any suggestions are appreciated,

Thanks,

- Maji
 
majiofpersia said:
Hi all,
I am wondering whether any of you knows how to initialize a
dynamically sized multi-dimensional array? I can't use arrayLists,
hashtables, or anything that is key value pair set-up...

An ArrayList is a vector, not a key pair construct. It sounds perfect
for your needs.
string[,,] myarray = new string[,,];

If do you not know the size of your dimensions, the ArrayList will come
in handy as you can simply add another ArrayList to achieve your second
dimension at run time.
 
Thanks for your responses,

If I am going to use arraylist ... how can I add items to a 3 dimensional
arraylist?

I like the class method suggested by Val as well .. I am just wondering
whether it is the only way ...

Thanks again,

- Maji


Frank Oquendo said:
majiofpersia said:
Hi all,
I am wondering whether any of you knows how to initialize a
dynamically sized multi-dimensional array? I can't use arrayLists,
hashtables, or anything that is key value pair set-up...

An ArrayList is a vector, not a key pair construct. It sounds perfect
for your needs.
string[,,] myarray = new string[,,];

If do you not know the size of your dimensions, the ArrayList will come
in handy as you can simply add another ArrayList to achieve your second
dimension at run time.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
 
majiofpersia said:
Thanks for your responses,

If I am going to use arraylist ... how can I add items to a 3
dimensional arraylist?

The ArrayList will accept any type of object so you can add an ArrayList
as an element of an existing ArrayList.
 
Back
Top