buggy ArrayList

  • Thread starter Thread starter Andreas Schulz
  • Start date Start date
A

Andreas Schulz

Hi,

when I recently used an ArrayList to store multiple string objects I
mentioned that there is no method for getting a specific value. The docu
says the Item property to get a specific element is not supported by the
compact framework. Fine, but how to get the values else? Inserting at a
specific position is no problem since there is an Add method with
several overloadings.

What I did to get the values back was to copy the ArrayList to a string
array by using the CopyTo method and then getting the values out of
string array.

But that can't be the way to do, can it?
 
Hi Andreas

you can access the elements like an array:
ArrayList arrList; -> arrList[1] to access the element on position 1

or

arrList.IndexOf(object o) -> find out an index of an object

hoped this will help you

greets
sascha
 
Thanks a lot Sascha. It works great and saves a lot of time.
-----Original Message-----
Hi Andreas

you can access the elements like an array:
ArrayList arrList; -> arrList[1] to access the element on position 1

or

arrList.IndexOf(object o) -> find out an index of an object

hoped this will help you

greets
sascha




Andreas said:
Hi,

when I recently used an ArrayList to store multiple string objects I
mentioned that there is no method for getting a specific value. The docu
says the Item property to get a specific element is not supported by the
compact framework. Fine, but how to get the values else? Inserting at a
specific position is no problem since there is an Add method with
several overloadings.

What I did to get the values back was to copy the ArrayList to a string
array by using the CopyTo method and then getting the values out of
string array.

But that can't be the way to do, can it?

.
 
Back
Top