Does any one have an example of how to create an ArrayList of objects?
i.e. ArrayList of ArrayLists or an ArrayList of Hashtables?
Thanks in advance
KC
It's like adding any other item to an ArrayList, and then retrieving
that.
For example, if you wanted to add a Hashtable to an ArrayList, then you
would do this:
// An array list.
ArrayList arrayList = new ArrayList();
// Add 100 hashtables.
for (int index = 0; index < 100; index++)
{
// Add a hashtable.
arrayList.Add(new Hashtable());
}
Now if you want to use one of the hashtables, you would have to cast the
item that the array list returns:
// Get the first hashtable.
Hashtable hashTable = (Hashtable) arrayList[0];
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Netmonster" <netmon...@yahoo.com> wrote in message
news:1102609431....@f14g2000cwb.googlegroups.com...
ie..
ArrayList x1 = new ArrayList();
x1.Add (your object here)
x1.Add( another object here)
etc....
"Netmonster" <netmon...@yahoo.com> wrote in message
news:1102615017.5...@z14g2000cwz.googlegroups.com...
The array list is self-allocating. So you just keep calling Add when
you need to in order to add a new Hashtable. You don't have to know how
many you need beforehand.
--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com
"Netmonster" <netmon...@yahoo.com> wrote in message
news:1102615017.5...@z14g2000cwz.googlegroups.com...
KC