IList Interface Implementation

Hi all. 

I'm trying to implement IList in a control I am creating. Basically, the control is a data access control that I use througout a particular application. 

The code:- 

Default Overloads Property Item(ByVal index As Integer) As Object Implements IList.Item

works fine. However, it gives a build error if I change Object to something else, i.e. I want to do:- 

Default Overloads Property Item(ByVal index As Integer) As DataRowView Implements IList.Item

Is this possible  If so, how can it be done  If not, is there a work around  

To summarise, I need the IList.Item property to accept System.Data.DataRowView instead of Object 

Thanks in advance,
NLC


Answer this question

IList Interface Implementation

  • igorss

    Just a shot in the dark, let me first ask:  Are you trying to create a custom collection.  If so, instead of implementing IList, I would suggest just Inheriting from CollectionBase (to have pretty much all the functionality already done for you).

    If that's not the case, I'm not sure of a way around it.  I just tried a few things and couldn't figure out how to do it.  So you'll either have to inherit from collectionbase (if that's suitable for your case) or just deal with a loosely typed implementation of IList until Generics come around.  :( 

  • zcr

    MartinJ to the rescue!  I originally was going to answer about the same thing, until I tried it and got an Overloading error, but never thought to just rename the private property...dang!

    For those of you interested in MartinJ's answer, go <a href="http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx id=94399&Page=1#94538">here</a>.

  • IList Interface Implementation