G
Guest
Hi All,
I have a piece of code where by I create an arraylist containing elements of
class type ActivityDetail, one of the routines used is generic and returns an
object array, but I can not cast back to ActivityDetail Array see snipet below
ArrayList arrayl = new ArrayList();
ActivityDetail det = new ActivityDetail();
arrayl.Add(det);
object[] obj = (object[]) arrayl.ToArray(typeof(object));
ActivityDetail[] detarr = (ActivityDetail[])obj;
Yet as all objects inherit object I thought this would be OK and I'm sure I
have done similar in the past. I just get invalid cast - any help or
explaination would be appreciated.
TrinityPete
I have a piece of code where by I create an arraylist containing elements of
class type ActivityDetail, one of the routines used is generic and returns an
object array, but I can not cast back to ActivityDetail Array see snipet below
ArrayList arrayl = new ArrayList();
ActivityDetail det = new ActivityDetail();
arrayl.Add(det);
object[] obj = (object[]) arrayl.ToArray(typeof(object));
ActivityDetail[] detarr = (ActivityDetail[])obj;
Yet as all objects inherit object I thought this would be OK and I'm sure I
have done similar in the past. I just get invalid cast - any help or
explaination would be appreciated.
TrinityPete