You need to do:

Entry[] _entries =
(Entry[])_tempentries.ToArray(System.Type.GetType("Entry"));

Which will cast it.  ArrayList returns an Array of Objects, not your
type.  If you inadvertently but in a different type you'll get an
exception thrown at runtime when you try to do this cast.  

-----Original Message-----
From: James Alexander [mailto:[EMAIL PROTECTED]] 
Sent: Monday, May 06, 2002 3:00 PM
To: [EMAIL PROTECTED]
Subject: [DOTNET] ArrayList.ToArray() Problems

I'm having a problem w/ the following:

Entry[] _entries = _tempentries.ToArray(System.Type.GetType("Entry"));

Entry is a struct I've created and _tempentries is an ArrayList holding
a collection of Entry's. I then want to create an Entry array however
everytime I attemp the above snippet, I get a "Cannot implicityly
convert type System.Array to Entry[]" error. I'm probably missing
something really simple hear, can someone please tell me what it is?

Thanks,

James

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to