Return whole List from collection class?

  • Thread starter Thread starter Gustaf
  • Start date Start date
G

Gustaf

I've got a collection class built on System.Collections.CollectionBase,
and I want a property that returns all the objects currently in the
collection, like this:

public Object[] Objects
{
get { return (Object[]) List; }
}

This conversion is illegal however. How shall I write instead?

Gustaf
 
Gustaf said:
I've got a collection class built on System.Collections.CollectionBase,
and I want a property that returns all the objects currently in the
collection, like this:

public Object[] Objects
{
get { return (Object[]) List; }
}

This conversion is illegal however. How shall I write instead?

Gustaf

It seemss as though the InnerList property will give you something you could at
least work with - it returns an ArrayList, which is indeed consists of Objects.
So, what about:

public ArrayList Objects
{
get ( return this.InnerList; }
}

(unless I misunderstand what you are after)

HTH,
-rick-
 
Back
Top