PC Review


Reply
Thread Tools Rate Thread

ArrayList.toArray() --> int[]

 
 
ChuckD_Duncan
Guest
Posts: n/a
 
      25th Aug 2005
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

 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      25th Aug 2005
>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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ArrayList.ToArray question GB Microsoft C# .NET 4 30th Aug 2006 12:43 AM
Problems with ArrayList::ToArray Dirk Microsoft VC .NET 2 1st Aug 2004 07:48 PM
ArrayList.ToArray() question Derrick Microsoft C# .NET 4 2nd Mar 2004 08:38 PM
Arraylist.ToArray(type) conversion PROBLEM Sunny Microsoft C# .NET 2 4th Jan 2004 02:47 AM
Re: ArrayList ToArray issues Jay B. Harlow [MVP - Outlook] Microsoft VB .NET 32 27th Aug 2003 10:10 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:56 AM.