dynamic array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • majiofpersia

    #1

    dynamic array

    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


  • Frank Oquendo

    #2
    Re: dynamic array

    majiofpersia wrote:[color=blue]
    > 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...[/color]

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

    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.




    Comment

    • majiofpersia

      #3
      Re: dynamic array

      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" <franko@acadx.c om> wrote in message
      news:#FkVLChVDH A.2212@TK2MSFTN GP12.phx.gbl...[color=blue]
      > majiofpersia wrote:[color=green]
      > > 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...[/color]
      >
      > An ArrayList is a vector, not a key pair construct. It sounds perfect
      > for your needs.
      >[color=green]
      > > string[,,] myarray = new string[,,];[/color]
      >
      > 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
      >
      >[/color]


      Comment

      • Frank Oquendo

        #4
        Re: dynamic array

        majiofpersia wrote:[color=blue]
        > Thanks for your responses,
        >
        > If I am going to use arraylist ... how can I add items to a 3
        > dimensional arraylist?[/color]

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

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




        Comment

        Working...