How'd they do that?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to implement a custom collection, but I'm having trouble trying to
duplicate some of the "features" found in the generic collections.
Specifically, implementing both the IEnumrable interface as well as the
IEnumerable<T> interface. When I click on "Goto Definition" of List<T> it
shows that List<T> implements both interfaces, but HOW?

IEnumerable<T> specifies a method like:

T GetEnumerator();

IEnumerable specifies a method like:

Object GetEnumerator();

You can't implement both because the signatures only differ by return type.
What trick am I missing?
 
microsoft.private.whidbey.csharp.ide || .language is the newsgroup you would
want to post to
 
You can't implement both because the signatures only differ by return type.
What trick am I missing?

Explicit implementation:

public IEnumerator<T> GetEnumerator() { ... }

IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator() }



Mattias
 
Back
Top