ArrayList.toArray() --> int[]

  • Thread starter Thread starter ChuckD_Duncan
  • Start date Start date
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
 
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
 
Back
Top