Inherited ArrayList doesn't show members on indexer.

I

Iulian Ionescu

I have the following problem. I derived a class from
ArrayList to provide some additional events I need. Then
I derived 2 different classes from this one and each of
them defines an indexer that returns the specified
object. For example, the list for Group types will have:

public new Group this[int index]
{
get
{return (Group)base[index];}
set
{base[index]=value;}
}

everything is fine, but if I do this:

someclass.Groups[0]. -> at this moment the members of the
Group object (returned by the indexer) do not show in the
intellisense drop down box. I know this is because the
ide "thinks" that the indexer returns the base item which
is object, or maybe because it doesn't know which one to
pick? However, this behaviour is pretty annoying and I
was wondering if anybody has any idea about what do I do
wrong?

Again, the list is derived directly from ArrayList and
then 2 different lists are derived from it and each list
implements the indexer that returns the required type.

Any help would be appreciated,
thank you!
Iulian
 
J

Jay B. Harlow [MVP - Outlook]

Iulian,
How is the someclass variable defined?

Instead of deriving from ArrayList have you considered deriving from
System.Collections.CollectionBase instead?

CollectionBase contains an ArrayList internally yet allows you to define
fully functional type safe collections (new/shadows on methods not
required).

Hope this helps
Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top