Thread: 2 Dimensional ArrayList

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    215

    2 Dimensional ArrayList

    Can anyone show me an example on how to create a two dimensional ArrayList?

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    There is no two dimensional array list. Depending on what you need, you can use a two dimensional array, an arraylist of arraylists or an arraylist of points. Maybe a SortedList would do. ( Hint: SortedList in .NET is not a sorted list. )
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Jan 2004
    Posts
    37
    This is how to create one:

    Code:
    ArrayList arrayList = new ArrayList();
    
    for (int i = 0; i < d1 ; i++)
    {
    
    ArrayList l2 = new ArrayList(); arrayList.Add(l2);
    }
    d1 is the length of the first dimension. At this point the variable arrayList is an ArrayList that has other ArrayLists as items. This is kind of pointless in my opinion, but it should work.

    LT

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    215
    Thanks guys! turns out I dont need to use it anymore, so thanks anyways!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multi dimensional array
    By $l4xklynx in forum C Programming
    Replies: 7
    Last Post: 01-03-2009, 03:56 AM
  2. ArrayList Basics - Example
    By wbeasl in forum C# Programming
    Replies: 2
    Last Post: 12-26-2008, 04:41 PM
  3. Two dimensional array
    By George2 in forum C Programming
    Replies: 3
    Last Post: 11-10-2007, 05:27 AM
  4. Trouble using ArrayList
    By stevespai in forum C# Programming
    Replies: 12
    Last Post: 07-31-2006, 11:17 AM
  5. Have you ever had a four dimensional experience
    By Silvercord in forum A Brief History of Cprogramming.com
    Replies: 35
    Last Post: 08-18-2003, 06:13 PM