Groups | Blog | Home
all groups > c# > may 2006 >

c# : List<T> and IList interface


KH
5/14/2006 10:18:01 PM
The IList members are implemented explicitly ("explicit interface
implementations" in msdn) -- so they will only be available when treating the
List<T> as a non-generic IList:

// disclaimer: untested code

System.Collections.IList list = new System.Collections.Generic.List<T>();
list.Add( new Object() );


[quoted text, click to view]
Rene
5/14/2006 10:31:03 PM
According to the documentation, the List<T> type explicitly implements the
non generic IList interface.

The problem is that no matter how hard I look, I am not able to find this
implemetion on the List<T> type. Could some one tell me where can I find the
IList implementation?

Please note that the plase where I am looking for this implementation is
from the Visula Studio metadata information page. The page that shows up
when you right-click on the "List<T>" word and then click on the "Go To
Definition" menu item.

This has to be something very stupid of my part, what am I missing?

Johan Appelgren
5/14/2006 11:01:38 PM
Looks like the object browser in Visual Studio hides explicit interface
implementations. You could use Lutz Roeder's .NET Reflector instead,
see <http://www.aisto.com/roeder/dotnet/>.
Rene
5/15/2006 12:30:34 AM
I already knew that, my question was: Where is that implementation on the
List<T> metadata? I don't see it. I should be able to see the explicit
implementation such as:

int IList.Add(object value);

take a second to re-read my original post a little more carefully and you
will see what I mean.

Thanks.


[quoted text, click to view]

Rene
5/15/2006 1:37:11 AM
Ah! Thanks, I thought I was going crazy!



[quoted text, click to view]

AddThis Social Bookmark Button