ArrayList.toArray() --> int[]

C

ChuckD_Duncan

By default ArrayList ToArray copies the list to object[]. There is an
override that allows the specification of a type:
ArrayList.ToArray(System.Type)... however, I have been unable to correctly
specify the system type or to figure out how to easily convert the object[]
to an int[].
Any ideas??

Thanks in advance.
Chuck
 
M

Mattias Sjögren

however, I have been unable to correctly
specify the system type or to figure out how to easily convert the object[]
to an int[].
Any ideas??

If the ArrayList contains all boxed ints you can do

int[] arr = (int[])yourArrayList.ToArray(typeof(int));



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top