I have a class that inherits from CollectionBase
.
public NavigationMenuItemsCollection MenuItems { get; set; }
I have a method that is attempting to get the item from the index, but it's not working.
public void ActivatePage(int index)
{
NavigationMenuItem navigationMenuItem = (NavigationMenuItem)MenuItems[0];
}
CollectionBase inherits from IList
, ICollection
, and IEnumerable
. So I thought it could be indexed. Any ideas on what's going on?
CollectionBase
implementsIList
's indexer property with an explicit interface implementation, meaning that you'd normally have to cast the collection as anIList
in order to have access to it.If you are able to modify the source code of
NavigationMenuItemsCollection
, you should be able to add an indexer to it yourself, as shown in the first example here.