>object[] obj = (object[]) arrayl.ToArray(typeof(object));
It should work if you change this to
object[] obj = (object[]) arrayl.ToArray(typeof(ActivityDetail));
>Yet as all objects inherit object I thought this would be OK
It's the type of the array itself (object[] vs ActivityDetail[]) that
matters, not what kind of objects that are actually referenced.
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
TrinityPete - 18 Aug 2005 12:06 GMT
Thanks Mattias,
I was sure I had used similar methodology before and couldn't work out why
it wasn't working as expected in this instance. I now see the
ArrayList.ToArray was using the incorrect class.
The thing that threw me was in the dubugger looking at an element in the
object array still had an underlying Sysyem Type of Activity Detail therefore
I believed the cast was valid.
Thanks for your input.
Pete.
> >object[] obj = (object[]) arrayl.ToArray(typeof(object));
>
[quoted text clipped - 8 lines]
>
> Mattias