Home All Groups Group Topic Archive Search About

Implemented interface methods are not available and do not show in Intellisense?

Author
25 Mar 2006 11:01 PM
Dave
I'm creating my own SortedList collection class that implements IDictionary,
ICollection, and IEnumerable.  The code compiles.

I am writing a unit test to exercise it.  I can create the object but none
of the methods like Add are available.  The only thing that shows in
Intellisense is:

Equals
GetHashCode
GetType
ToString

What am I doing wrong??

Author
26 Mar 2006 7:28 AM
Jon Skeet [C# MVP]
Dave <n***@nowhere.com> wrote:
> I'm creating my own SortedList collection class that implements IDictionary,
> ICollection, and IEnumerable.  The code compiles.
>
> I am writing a unit test to exercise it.  I can create the object but none
> of the methods like Add are available.  The only thing that shows in
> Intellisense is:
>
> Equals
> GetHashCode
> GetType
> ToString
>
> What am I doing wrong??

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

If you've implemented the interface explicitly (i.e. your methods look
like void IDictionary.Add (...) etc) then you'll need to cast the
subject of your test to the interfaces before calling the method:

IDictionary dict = sortedList;
dict.Clear (...)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

AddThis Social Bookmark Button